saint
saint

Reputation: 95

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

Upvotes: 8

Views: 10540

Answers (1)

Ortsigat
Ortsigat

Reputation: 1309

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"
                }
                ]...

Upvotes: 15

Related Questions