Experiencing a weird issue with merge requests. I have a pipeline setup for merge requests to build an image with the code changes in the MR and then run some code tests. This pipeline uses Kaniko on kubernetes to build containers.
I have made changes to requirements.txt in a merge request, the build is failing. When i look at the log its still pulling in the old version of the pip dependency even though the MR only has an update to the pip dependency versions in requirements.txt
I thought this was an issue with kaniko layer caching and have that disabled - I am now really confused as to what is going on.
Relevant sections from my .gitlab-ci.yml
.kaniko-build:
variables:
container: docker
KANIKO_ARGS: ""
# PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
IMAGE_TAG: $CI_COMMIT_SHORT_SHA
image:
name: gcr.io/kaniko-project/executor:v1.7.0-debug
entrypoint: [""]
# cache:
# key: project-cache
# paths:
# - .cache/pip
script:
- |
if [ "$CI_COMMIT_REF_NAME" = $CI_DEFAULT_BRANCH ]; then
VERSION="latest"
elif [ -n "$CI_COMMIT_TAG" ];then
NOSLASH=$(echo "$CI_COMMIT_TAG" | tr -s / - )
SANITIZED="${NOSLASH//[^a-zA-Z0-9\-\.]/}"
VERSION="$SANITIZED"
else \
NOSLASH=$(echo "$CI_COMMIT_REF_NAME" | tr -s / - )
SANITIZED="${NOSLASH//[^a-zA-Z0-9\-]/}"
VERSION="branch-$SANITIZED"
fi
- echo $VERSION
- mkdir -p /kaniko/.docker
- |-
KANIKOPROXYBUILDARGS=""
KANIKOCFG="\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}"
if [ "x${http_proxy}" != "x" -o "x${https_proxy}" != "x" ]; then
KANIKOCFG="${KANIKOCFG}, \"proxies\": { \"default\": { \"httpProxy\": \"${http_proxy}\", \"httpsProxy\": \"${https_proxy}\", \"noProxy\": \"${no_proxy}\"}}"
KANIKOPROXYBUILDARGS="--build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} --build-arg no_proxy=${no_proxy}"
fi
KANIKOCFG="{ ${KANIKOCFG} }"
echo "${KANIKOCFG}" > /kaniko/.docker/config.json
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}/$DOCKERFILE_PATH"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
"${KANIKOPROXYBUILDARGS}"
--destination "${CI_REGISTRY_IMAGE}/${CONTAINER_NAME}:${VERSION}"
--build-arg CI_JOB_TOKEN
--build-arg BUILD_AGENT_ACCESS_KEY
# --cache=true
- echo "VERSION=$VERSION" >> build.env
artifacts:
reports:
dotenv: build.env
build project_base_image:
stage: build-project
extends: .kaniko-build
variables:
DOCKERFILE_PATH: project_base_image
CONTAINER_NAME: project_base_image
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
allow_failure: false
- if: '$CI_COMMIT_REF_NAME == "main"'
when: always
- if: $CI_PIPELINE_SOURCE == 'pipeline' && $CTB == 'project-base'
when: always
- when: manual
interruptible: true