0

How to use curl command with a wildcard for deploying an artifact to Jfrog Artifactory repo.
I'm trying to use the below from Jenkins pipeline script, and getting an error.

    stage 'Deploy Aritfacts to Artifactory'

    withCredentials([usernameColonPassword(credentialsId: '<enter credentials ID>', variable: 'password')])     {
            sh "    curl -k -u $password -T ${WORKSPACE}/soureCode/integration/dan-0.0.1-SNAPSHOT.zip "https://<enter artifactory URL>/maven-prereleases-local/com/dan/     "

When you run a build, it actually generates an artifact dan-0.0.1-SNAPSHOT.zip, I'm trying to use a wildcard for artifact version, instead of using a hardcode version. but got an error as shown below

 curl: Can't open '/bld/workspace/demoPipeline/soureCode/integration/dan-*-SNAPSHOT.zip'!
    curl: try 'curl --help' or 'curl --manual' for more information
Finished: FAILURE                                        
rohit thomas
  • 2,302
  • 11
  • 23
itgeek
  • 549
  • 1
  • 15
  • 33

2 Answers2

1

Are you allowed to use the Jenkins Artifactory plugin? This would give you access to the jfrog cli allowing use of uploadSpec's

def server = Artifactory.server 'artifactory'
def uploadSpec = """{
                      "files": [
                          {
                           "pattern": "${WORKSPACE}/soureCode/integration/dan-*-SNAPSHOT.zip",
                           "target": "maven-prereleases-local/com/dan/"
                          }
                      ]
                    }"""
server.upload(uploadSpec)
metalisticpain
  • 2,698
  • 16
  • 26
0

Unfortunately curl does not support wildcard '*', so what you can do is search for the file/location of the file and then pass it into your curl command

like so

curl -k -u $password -T $localFilePath $targetFolder/$fileName
rohit thomas
  • 2,302
  • 11
  • 23