cloud-native-toolkit / cloud-native-toolkit/planning
Jenkins build image stage fails when registry namespace does not exist
- Dominant language
- No language data
- Stars
- 4
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
The "Build image" stage in the Jenkins pipeline assumes that the container registry already has the namespace that the stage will push the image into. When this namespace doesn't exist, the push fails and the stage fails. The stage needs to confirm that the namespace already exists in the registry--and if not, create it--before attempting to push the image.
----------
Details:
Ran the Jenkins pipeline in a new environment. The "Build image" stage failed; from the logs:
```
BUILDING CONTAINER IMAGE: us.icr.io/garage-cloud-surge/stockbffnode-bw:1.0.0
Sending build context to Docker daemon 335.6MB
FAILED
Status: You are not authorized to access the specified resource., Code: 1
```
Was able to reproduce the problem from the command line:
```
$ docker push us.icr.io/garage-cloud-surge/stockbffnode-bw:1.0.0
The push refers to repository [us.icr.io/garage-cloud-surge/stockbffnode-bw]
af0b15c8625b: Preparing
denied: requested access to the resource is denied
```
Was able to create the namespace and successfully push:
```
$ ibmcloud cr namespace-add garage-cloud-surge
Adding namespace 'garage-cloud-surge'...
Successfully added namespace 'garage-cloud-surge'
OK
$ ibmcloud cr namespace-list
Listing namespaces for account 'IBM' in registry 'us.icr.io'...
Namespace
bw-temp
garage-cloud-surge
OK
$ docker push us.icr.io/garage-cloud-surge/stockbffnode-bw:1.0.0
The push refers to repository [us.icr.io/garage-cloud-surge/stockbffnode-bw]
af0b15c8625b: Mounted from bw-temp/hello-world
1.0.0: digest: sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a size: 524
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.