How to inject passwords to the build as environment variables(these are job passwords) for deployment through ansible via pipeline or dsl script
Asked
Active
Viewed 1,822 times
1 Answers
1
First, those job passwords should be registered as credentials inside Jenkins.
Second, you can use said file when calling your ansible-playbook
command, through the Credentials Binding plugin.
See "How to use multiple credentials in withCredentials in Jenkins Pipeline"
node {
withCredentials([
usernamePassword(credentialsId: credsId1, usernameVariable: 'USER1', passwordVariable: 'PASS1'),
usernamePassword(credentialsId: credsId2, usernameVariable: 'USER2', passwordVariable: 'PASS2')
...
]) {
sh '''
set +x
ansible-playbook /path/to/ansible-playbook.yml -i /path/to/hosts_list -u AUTO_USER --private-key=/path/to/private-key \
-e $USER1=$PASS1 -e $USER2=$PASS2
'''
}
}
Note: the file should have a JSON content, with your

VonC
- 1,262,500
- 529
- 4,410
- 5,250