Answers: <p>Create String parameter <code>artifactID</code>, Password parameter <code>NexusUser</code> with username and Password parameter <code>NexusPassword</code> with nexus password.</p>
  
  <p><code>curl -v -u $NexusUser:$NexusPassword -o ~/tmp_dl/distr.zip https://my_nexus_url.com/nexus/content/repositories/${artifactID}/distrib.zip</code></p>
  
Answers: CC BY-SA 4.0
Answers: 2020-05-15T02:27:16.367Z
Answers: In all likelihood @this will end up exposing the username/password bin cleartext in the logs. So you should also use the [Mak Paawords plugin](https://plugins.jenkins.io/mask-passwords/). Use credentials approach instead.
Answers: Ian W
Answers: CC BY-SA 4.0
Answers: 2020-03-05T08:15:33.450Z
Answers: 2020-03-05T08:15:33.450Z
Answers: Stepan
Answers: <p>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 <a href="https://jenkins.io/doc/pipeline/steps/ssh-agent/" rel="nofollow noreferrer">sshagent</a> step in your Pipeline script:</p>
  
  <pre><code>sshagent(credentials: ['my-credentials']) {
    sh('scp mynexus.com/my_artifact.zip ~/my_artifact.zip')
  }
  </code></pre>
  
  <p>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.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-03-03T07:15:33.063Z
Answers: 2020-03-03T07:15:33.063Z
Answers: jayhendren
Body: <p>I use <code>ssh username and private key</code> 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.</p>
  
  <p>Is there a way to run <code>scp mynexus.com/my_artifact.zip ~/my_artifact.zip</code> and pass username with password from Jenkins credentials?</p>
  
Tags: <jenkins><nexus><ssh>
Title: Download an artifact from Nexus to Jenkins
UserDisplayName: Stepan
ThreadText: # Download an artifact from Nexus to Jenkins
  
  (Asked by: username_0 on 2020-03-03)
  
  I use `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?
  
  **Tags:** jenkins, nexus, ssh
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2020-03-05. Score: 1
  
  Create String parameter `artifactID`, Password parameter `NexusUser` with username and Password parameter `NexusPassword` with nexus password.
  
  `curl -v -u $NexusUser:$NexusPassword -o ~/tmp_dl/distr.zip https://my_nexus_url.com/nexus/content/repositories/${artifactID}/distrib.zip`
  
  > **Comments:**
  > **username_1**: In all likelihood @this will end up exposing the username/password bin cleartext in the logs. So you should also use the [Mak Paawords plugin](https://plugins.jenkins.io/mask-passwords/). Use credentials approach instead.  
  
  ---
  
  ### Answer by username_2 on 2020-03-03. Score: 1
  
  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](https://jenkins.io/doc/pipeline/steps/ssh-agent/) step in your Pipeline script:
  
  ```
  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.
  
  
  ---
  
  