Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I upload multiple pattern files using artifactory/jfrog in jenkinsfile

I am trying to upload multiple patterns like .zip and .tar.gz using Artifactory/Jfrog Files in Jenkins.

here is my code

                def uploadSpec = """{
                "files": [
                {
                    "pattern": "(*.zip | *.tar.gz)",
                    "target": "${upload_loc}/${BRANCH_NAME}/",
                    "recursive": "true",
                    "flat": "false",
                    "props": "Version=${Version};Branch=${BRANCH_NAME}"
                }
                ]
                }"""

I tried above syntax and it's not working for me, it says 0 artifcats found. can any one suggest if they encounter similar scenario.

Thanks and Regards Saint

like image 242
saint Avatar asked Apr 05 '18 17:04

saint


People also ask

How do I push JAR files to a Jfrog Artifactory repository?

Here are four different ways to push JAR files to a JFrog Artifactory repository. 1. Upload to the Artifactory repository manually

How do I pull Artifactory files from Jenkins?

For example, to pull Artifactory every ten minutes, set */10 * * * * 4. Set a Path to watch. For example, when setting generic-libs-local/builds/starship, Jenkins polls the /builds/starship folder under the generic-libs-local repository in Artifactory for new or modified files.

What is Jfrog's Jenkins Artifactory plugin for DevOps?

For organizations in pursuit of DevOps enlightenment, it's the CI/CD build that should be pushing packaged artifacts to an Artifactory repository. Fortunately, JFrog provides a Jenkins Artifactory plugin that facilitates automation of the process.

How do I integrate Jfrog with Jenkins?

Setting Up the Integration 1 Open the JFrog Piplines UI. 2 Under Integrations, click on the Add an Integration button. 3 Choose Jenkins Server integration type and fill out all of the required fields. 4 Click on the Generate button to generate a token. This token is used by Jenkins to authenticate with JFrog Pipelines.


1 Answers

You have 2 options:

Option 1 - Use a regular expression to describe your patterns.

In your example something like this should work:

    ...
    "pattern": "(.*\.zip|.*\.tar\.gz)",
    "regexp":"true",
    ...

Note that if you do so, you have to add the flag regexp=true.

(I use this website to test my expressions. note that you have to check golang as your flavor)

Option 2 - Use multiple files in a single spec (what I would probably do in your case).

In your example something like this should work:

..."files": [
                {
                    "pattern": "*.tar.gz",
                    "target": "${upload_loc}/${BRANCH_NAME}/",
                    "recursive": "true",
                    "flat": "false",
                    "props": "Version=1"
                },
                {
                    "pattern": "*.zip",
                    "target": "${upload_loc}/${BRANCH_NAME}/",
                    "recursive": "true",
                    "flat": "false",
                    "props": "Version=1"
                }
                ]...
like image 197
Ortsigat Avatar answered Jan 04 '23 11:01

Ortsigat