I'm building a Docker image with Kaniko. I would like to use two separate private artifactories for my GitLab CI/CD pipeline:
- One from which the Dockerfile takes its source image (Artifactory1/Repo1)
- One to which the pipeline will push the ready image (Artifactory2/Repo2)
Both have separate credentials.
My question is, how could I add the login credentials for the second, destination artifactory? I have tried with -u -p flags, and also with a separate line, did not work.
As of now my gitlab-ci.yml code looks something like this:
image:
name: artifactory1/kaniko/executor:debug
entrypoint: [""]
stages:
- build
build:
stage: build
script:
- env
- KANIKOCFG="\"auths\":{\"artifactory1/repo1/\":{\"auth\":\"$(printf "%s:%s" "${ARTIFACTORY1_USER}" "${ARTIFACTORY1_PASS}" | base64 | tr -d '\n')\"}}"
- KANIKOCFG="{ ${KANIKOCFG} }"
- echo ${KANIKOCFG} >> /kaniko/.docker/config.json
- /kaniko/executor --dockerfile $CI_PROJECT_DIR/Dockerfile --context $CI_PROJECT_DIR/ --destination artifactory2/repo2/finalimage:1.0.0
Both artifactory1 and artfactory2 credentials are known and added to GitLab as variables, something like this:
ARTIFACTORY1_USER
ARTIFACTORY1_PASS
ARTIFACTORY2_USER
ARTIFACTORY2_PASS
I'm always getting an authentication error for REPO2 that I cant push there. Of course now it does not work because I could not set authentication up in the correct way.