Skip to content

Instantly share code, notes, and snippets.

@subinamathew
Created November 14, 2023 09:24
Show Gist options
  • Save subinamathew/9b6cc9ce51403be911e4070695d9e4bd to your computer and use it in GitHub Desktop.
Save subinamathew/9b6cc9ce51403be911e4070695d9e4bd to your computer and use it in GitHub Desktop.
Jenkins cURL with USERNAMEPASSWORD and Variable
pipeline {
agent {
node {
label 'master'
customWorkspace "${JENKINS_HOME}/workspace/${JOB_NAME}/${BUILD_NUMBER}"
}
}
stages {
stage('HELLO') {
steps {
withCredentials([
string(credentialsId: 'secretText', variable: 'pwd1'),
usernameColonPassword(credentialsId:'key2', variable: 'USERPASS')
]) {
script {
def json = readJSON(text: readFile("./output.json").trim())
json.results.each { result ->
def DAT = result.name
sh "curl -sS -u"+ USERPASS + " https://myrepo.com/${DAT} -O"
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment