Hi, I am trying to access my Gitlab registry using Personal Access Token. I want to push image to my project container registry.
For the PAT I have the scope of read_registry
and write_registry
. Then I add the PAT as Secret text in Jenkins. However when I run my pipeline, I got this error.
my pipeline script:
withCredentials([string(credentialsId: 'gitlab-token', variable: 'GITLAB_TOKEN')]) {
sh "echo $GITLAB_TOKEN | docker login registry.gitlab.com -u username --password-stdin"}
my error:
Error response from daemon: Get “https://registry.gitlab.com/v2/”: unauthorized: HTTP Basic: Access denied. If a password was provided for Git authentication, the password was incorrect or you’re required to use a token instead of a password. If a token was provided, it was either incorrect, expired, or improperly scoped. See Troubleshooting two-factor authentication | GitLab
script returned exit code 1
How to solve this issue. Thanks in advance.