(method: username and password)
Jenkinsで名前を使用して資格情報を作成しましたwwe_hello
。テストのために、私は名前でパイプラインを作成しましたtest
:
pipeline {
agent {label 'slave1'}
environment {
CREDS = credentials("wwe_hello")
}
stages {
stage('WWE') {
steps {
sh 'echo "$CREDS"'
}
}
}
}
結果として私は持っています:
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on slave1 in /var/lib/jenkins/workspace/test
[Pipeline] {
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: wwe_hello
Finished: FAILURE
どこで、私はエラーがあります。私は実際の例とドキュメントに従ってすべてを行っています。しかし、なぜそれが機能しないのか、私にはわかりません。
withCredentialsのパイプラインステップのドキュメントをご覧ください。envを使用して環境変数を作成する必要はありません。withCredentialsが作成します。
pipeline {
agent any
stages {
stage('only') {
steps {
withCredentials([
usernamePassword(
credentialsId: 'CRED',
usernameVariable: 'USER',
passwordVariable: 'PASS'
)]) {
sh '''
echo "The username is: ${USER}"
echo "The password is : ${PASS}"
'''
}
}
}
}
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加