wardviaene/jenkins-course

Cloudbees build and publish access denied

Closed this issue · 1 comments

When I try to use the cloudbees plugin to build and publish a docker image I get the following error:
denied: requested access to the resource is denied
Build step 'Docker Build and Publish' marked build as failure

I have configured the correct registry credentials and use the same example as you have. I also created a repository on dockerhub. I also tried to add an execute shell buildscript before the build and publish with the following command 'docker login -u USERNAME -p PASSWORD and then it worked without problem. But obviously I can't leave my password in plaintext in the configuration. Anybody else having this issue?

Full error in Jenkins:
Started by user svc_tmserver
[EnvInject] - Loading node environment variables.
Building in workspace /var/jenkins_home/jobs/hello-world/workspace
using credential 871b61e0-113b-43b4-95b8-fcc823fe3ca5

git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://gitlab.com/RuneHanssens/hello-world-2.git # timeout=10
Fetching upstream changes from https://gitlab.com/RuneHanssens/hello-world-2.git
git --version # timeout=10
using GIT_ASKPASS to set credentials
git fetch --tags --progress https://gitlab.com/RuneHanssens/hello-world-2.git +refs/heads/:refs/remotes/origin/
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision c09d3c94944d9cef36549e918d036824e601bd37 (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f c09d3c94944d9cef36549e918d036824e601bd37
Commit message: "added dockerfile"
git rev-list --no-walk c09d3c94944d9cef36549e918d036824e601bd37 # timeout=10
[workspace] $ /bin/sh -xe /tmp/jenkins7585591487026862113.sh
[workspace] $ docker build -t runehanssens/hello-world --pull=true /var/jenkins_home/jobs/hello-world/workspace
Sending build context to Docker daemon 80.38kB
Step 1/6 : FROM node:alpine
alpine: Pulling from library/node
Digest: sha256:a93cc66176b000e09f7011622c9f2f0faa982fe7e01c961b2506e14b07834175
Status: Image is up to date for node:alpine
---> 4c6406de22fd
Step 2/6 : WORKDIR /app
---> Using cache
---> bf0dcad1057d
Step 3/6 : ADD . /app
---> Using cache
---> f62193498aca
Step 4/6 : RUN npm install
---> Using cache
---> cf049611a897
Step 5/6 : EXPOSE 3001
---> Using cache
---> 94368feeec01
Step 6/6 : CMD npm start
---> Using cache
---> 394875cc21de
Successfully built 394875cc21de
Successfully tagged runehanssens/hello-world:latest
[workspace] $ docker inspect 394875cc21de
[workspace] $ docker push runehanssens/hello-world
The push refers to repository [docker.io/runehanssens/hello-world]
bb6c028492f7: Preparing
81902eb9f4ba: Preparing
87f557d84778: Preparing
8977df70d24f: Preparing
a2228fbe95fa: Preparing
fe1f3c52b497: Preparing
f1b5933fe4b5: Preparing
fe1f3c52b497: Waiting
f1b5933fe4b5: Waiting
denied: requested access to the resource is denied
Build step 'Docker Build and Publish' marked build as failure
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

Asked the same question in the q&a of udemy.