Images are not build when re-triggered
I re-triggered a job because the underlying image was changed, but the job didn't build an image, see https://0xacab.org/leap/gitlab-buildpackage/-/jobs/24331
It's because we check the LAST_COMMIT of the latest pipeline against current master.
If the pipeline is already run for this commit, git diff $LAST_COMMIT HEAD --name-only
results in no output:
before_script:
- >
export LAST_COMMIT=$(curl -s
--header "PRIVATE-TOKEN: ${LEAP_CODE_O_MATIC_PRIVATE_TOKEN}"
https://0xacab.org/api/v4/projects/506/pipelines |
python -c "import sys, json; print json.load(sys.stdin)[1]['sha']")
script:
- >
if git diff $LAST_COMMIT HEAD --name-only |
egrep "(docker/${CI_JOB_NAME}|common|fetch-sources|jenkins|repohost|.gitlab-ci.yml)";
then
docker --version
docker info
docker login -u gitlab-ci-token -e sysdev@leap.se -p $CI_JOB_TOKEN $CI_REGISTRY
docker build -t ${CI_REGISTRY_IMAGE}:${CI_JOB_NAME} -f docker/${CI_JOB_NAME}/Dockerfile .
docker push ${CI_REGISTRY_IMAGE}:${CI_JOB_NAME}
fi