Search code examples
bashjenkins-pipelineartifactory

How to download Artifactory from JFrog Artifactory via terminal?


I am working on Jenkinsfile and for the project I need to get some Artifactory, can anyone help me with the correct command?

I was thinking about curl but then it is asking me for username and password, follow by a 404 error.


Solution

  • In the stage in your Jenkinsfile, use your download command within a withCredentials directive.

    withCredentials([usernamePassword(credentialsId: 'artifactoryCredentials', passwordVariable: 'ART_PASSWORD', usernameVariable: 'ART_USERNAME')]) {
        sh 'curl -u ${ART_USERNAME}:${ART_PASSWORD} https://artifactory.example.com/artifactory/foo/com/projectA/wrapper/app-1.0.jar'
    }
    

    If you're using wget to download your packages, use the below within sh block.

    wget --user ${ART_USERNAME} --password ${ART_PASSWORD} https://artifactory.example.com/artifactory/foo/com/projectA/wrapper/app-1.0.jar
    

    Please check with the Admin on the right credentialsId to use within your Jenkins pipeline.

    For more info on handling credentials refer Jenkinsfile documentation.