-
Bug
-
Resolution: Unresolved
-
Major
-
None
I try to use a user credential in declafative pipeline which I select via a credential parameter.
The parameter selection allows me to pick a credential which is scoped to my user.
How ever if I try later on to the selected credential in a withcredential block I get an error mo such credential. If I pick a credential wit scope global the code works.
pipeline {
agent none
tools {
jdk 'JDK 11'
maven 'Maven 3.8.4'
}
options {
buildDiscarder logRotator(
artifactDaysToKeepStr: '',
artifactNumToKeepStr: '3',
daysToKeepStr: '',
numToKeepStr: '5')
}
parameters {
credentials credentialType: 'com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey',
name: 'DEPLOY_CRED', required: true, defaultValue: '',
description: 'The credential used on the target systems for the deployment (Username, SSH Key)'
}
stages {
stage( 'public') {
agent any
steps {
echo "Deploy monitoring on XXX as ${DEPLOY_CRED{color:#569cd6"}}
withCredentials([sshUserPrivateKey(credentialsId: DEPLOY_CRED ,
keyFileVariable: 'KEY_PATH',
usernameVariable: 'REMOTE_USER' )]) {
sh 'cp -f $KEY_PATH luckilucki.txt'
echo "${REMOTE_USER{color:#569cd6 ${KEY_PATH{color:#569cd6}}"}}
}
}
}
}
}