Reputation: 1039
I've a simple Jenkins pipeline which will pull a docker image (from a private registry)and execute command, I'm failing to understand as despite providing credential ID, pipeline fails with error message ERROR: Could not find credentials matching docker-cred
Pipeline:
pipeline
{
agent
{
docker {
image "xxxxxxx/dotnet:latest"
registryUrl 'xxxxxxx'
registryCredentialsId "docker-cred"
reuseNode true
}
}
stages
{
stage('Test')
{
steps
{
sh 'dotnet --version'
}
}
}
}
Credentials added:
Upvotes: 3
Views: 8358
Reputation: 1
I used to pass it on like this:
stage("Docker Build & Push"){
steps{
script{
withDockerRegistry(credentialsId: 'docker', toolName: 'docker')
Hope it helps
Upvotes: 0
Reputation: 8794
I had the same problem. For me, after moving the credential to the global domain, the problem resolved.
Upvotes: 0
Reputation: 61
According to the documentation you need to use "Username/Password" credentials type:
For a Docker Registry which requires authentication, add a "Username/Password" Credentials item from the Jenkins home page and use the Credentials ID as a second argument to withRegistry(): ...
Upvotes: 6