Jenkins credentials

 

environment {
MAGE_REPO_CREDENTIALS = credentials('COMPOSER_REPO_MAGENTO')
COMPOSER_AUTH = """{
  "http-basic": {
      "repo.magento.com": {
          "username": "${env.MAGE_REPO_CREDENTIALS_USR}",
          "password": "${env.MAGE_REPO_CREDENTIALS_PSW}"
      }
  } }"""
}

  

withCredentials([usernamePassword(credentialsId: 'amazon', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
// available as an env variable, but will be masked if you try to print it out any which way
// note: single quotes prevent Groovy interpolation; expansion is by Bourne Shell, which is what you want
sh 'echo $PASSWORD'
// also available as a Groovy variable
echo USERNAME
// or inside double quotes for string interpolation
echo "username is $USERNAME"
}

 

Reference

https://www.cnblogs.com/FLY_DREAM/p/13888423.html

posted @ 2021-05-27 14:47  i舒  阅读(407)  评论(0编辑  收藏  举报