I created a credentials parameter TEST_CREDENTIALS , and when i try to inject as ssh plugin agent parameterized as ${TEST_CREDENTIALS}, i see the below error
java.io.IOException: [ssh-agent] Could not find specified credentials
I created a credentials parameter TEST_CREDENTIALS , and when i try to inject as ssh plugin agent parameterized as ${TEST_CREDENTIALS}, i see the below error
java.io.IOException: [ssh-agent] Could not find specified credentials
Creating a Credential in Jenkins does not mean that an environment variable is created automatically.
This is what you do in a pipeline job to "get at" the credential details, namely the username and password.
.
.
.
environment {
ARTIFACTORY_CID = 'CREDENTIAL_NAME'
}
withCredentials([usernamePassword(credentialsId: "${env.ARTIFACTORY_CID}", passwordVariable: 'p_password', usernameVariable: 'p_username')]) {
server.username = "${p_username}"
server.password = "${p_password}"
}
CREDENTIAL_NAME should be a human-readable descriptive name for your credential (I like to name things based on the function they perform).
withCredentials([...])
is the pipeline clause that puts the components of the credential (username and password in this case) into environment variables for you.
Given that in this example my credential type is "Username with password" I have to use usernamePassword(...)
. If my credential type was "SSH Username with private key" I would use sshUserPrivateKey(...)
.
usernameVariable
sets the name of a new environment variable for the username.
passwordVariable
sets the name of a new environment variable for the password.
You can then access and make use of the username and password values from the credential using the environment variables ${p_username}
and ${p_password}
.