patternMinor
Download an artifact from Nexus to Jenkins
Viewed 0 times
artifactjenkinsnexusdownloadfrom
Problem
I use
Is there a way to run
ssh username and private key auth to download sources from Git, build the artifact and deploy it to my nginx server. Now I need to download an artifact as a zip file to Jenkins agent, prepare it and deploy to my nginx server. I can only access Nexus using username/password pair.Is there a way to run
scp mynexus.com/my_artifact.zip ~/my_artifact.zip and pass username with password from Jenkins credentials?Solution
There are a few ways to do this, but by far the easiest is to put your credentials (either username/password or ssh keypair) into the Jenkins built-in credentials store and then use the sshagent step in your Pipeline script:
You may need to install the SSH Agent plugin to be able to use this step; I'm not sure if it's part of the default set of Pipeline plugins or not.
sshagent(credentials: ['my-credentials']) {
sh('scp mynexus.com/my_artifact.zip ~/my_artifact.zip')
}You may need to install the SSH Agent plugin to be able to use this step; I'm not sure if it's part of the default set of Pipeline plugins or not.
Code Snippets
sshagent(credentials: ['my-credentials']) {
sh('scp mynexus.com/my_artifact.zip ~/my_artifact.zip')
}Context
StackExchange DevOps Q#10975, answer score: 1
Revisions (0)
No revisions yet.