8

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

saint
  • 95
  • 1
  • 9
  • Are you sure you are running the upload command in the same directory where your files are present? – KatariaA Apr 06 '18 at 07:50
  • in regexp, wildcard is `.*` (`.` stands for "any character" and `*` stands for "any number of times"), not just `*` so this is invalid. You also need to enable regexp by using `"regexp": "true"` in your spec. See https://stackoverflow.com/questions/12666768/how-dot-star-works for an explanation of the regex syntax in this case. – Florian Castellane Jun 14 '18 at 10:33

1 Answers1

15

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"
                }
                ]...
Ortsigat
  • 1,259
  • 7
  • 8
  • I opted for the 1st option (well done!), but i receive this odd error: `WorkflowScript: 75: unexpected char: '\'` at startup. My regexp is `"pattern": "(.*\.zip|.*\.war|pom.xml)"` – andreagalle Sep 22 '22 at 10:00