Created
November 14, 2023 09:24
-
-
Save subinamathew/9b6cc9ce51403be911e4070695d9e4bd to your computer and use it in GitHub Desktop.
Jenkins cURL with USERNAMEPASSWORD and Variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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