stage ("E2E tests") {
environment {
mySecret = credentials('${mySecret}')
}
steps {
script {
STAGE_NAME = "E2E tests"
echo "++++++++++++ $mySecret"
if (JOB_NAME == "e2e-dev") {
// Setup packages and run tests
sh '''
rm -f config/e2e-config.json
mv config/e2e-dev-config.json config/e2e-config.json
npm install
npm test
'''
}
}
}
}
stage ("E2E tests") {
when { branch 'e2e-dev' } environment { MY_SECRET = credentials('jenkins-secret-id') } steps { sh 'rm -f config/e2e-config.json' sh 'mv config/e2e-dev-config.json config/e2e-config.json' sh 'npm install' sh 'npm test' }}
withCredentials([string(credentialsId: 'credential-id-here', variable: 'CUSTOM_VARIABLE_NAME_HERE')]) { sh "MY_SECRET=CUSTOM_VARIABLE_NAME_HERE npm test"}
These key-value pairs apply for every build on every node. They can be used in Jenkins' configuration (as $key or ${key}) and will be added to the environment for processes launched from the build. |
environment {
myPassword = credentials('${myPassword}')
...
}
{"property":"value", "property": "value", "property": "value", "property": "value"}