I am trying to access AWS credentials provided via a parameter in my pipeline job.
I have a pipeline job where I am using an AWS credentials parameter defined like this:
credentials (
credentialType: 'com.cloudbees.jenkins.plugins.awscredentials.AWSCredentialsImpl',
defaultValue: 'jenkins-deploy-proj',
description: '''
My description
''',
name: 'AWS_ACCOUNT'
)
I got that via "Pipeline Syntax > Declarative Directive Generator > Parameters" in the Jenkins UI.
I need to access those credentials later in the in the job. From other discussions it seems to be that I should use a withCredentials block to access the credentials , so I tried this
script {
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY',
credentialsId: "${params.AWS_ACCOUNT}"
]]) {
sh 'bash myscript.sh'
}
}
I got that via "Pipeline Syntax > Snippet Generator > withCredentials" in the Jenkins UI.
The pipeline runs fine with the default credentials (which are accessible to all users) but when I attempt to use my personal credentials (still in the global domain) I get an error from Jenkins telling me that the credentials don't exist:
ERROR: Could not find credentials entry with ID '557ff283-70f3-402b-b065-fb4c9f28305e'
I can use those same credentials as a parameter in other (non-pipeline) Jenkins jobs configured like this, and they work fine:
I did make take an extra step to make sure the problem wasn't just with that one credential object by creating a new credential object, but I got the same Could not find credentials entry with ID error.

