Commit 72f0feb9 authored by Adelina Eleonora Lintuluoto's avatar Adelina Eleonora Lintuluoto Committed by Clemens Lange
Browse files

add pipeline for building docker images

parent c77d4567
stages:
- check
- build
before_script:
- export DATE=$(date +"%Y-%m-%d")
variables:
COMMIT_HASH: $CI_COMMIT_SHORT_SHA
check changed files:
stage: check
only:
changes: [cc7-cms/*, cc7-cvmfs/*, slc6-cms/*, slc6-cvmfs/*, slc5-cms/*]
except:
- pipelines
tags:
- docker
script:
- ./check.sh
build standalone:
stage: build
only:
variables:
- $CMSSW_VERSION && $SCRAM_ARCH && $BASE_IMAGE
variables:
REPO_NAME: standalone
IMAGE_NAME: cmssw
tags:
- docker-privileged-xl
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- echo "Building standalone image $BASE_IMAGE with $CMSSW_VERSION and $SCRAM_ARCH"
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR/$REPO_NAME --dockerfile $CI_PROJECT_DIR/$REPO_NAME/Dockerfile --destination $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CMSSW_VERSION-$DATE-$COMMIT_HASH --build-arg=BUILD_DATE="$DATE" --build-arg=VERSION="$DATE" --build-arg=VCS_URL="$CI_REPOSITORY_URL" --build-arg=VCS_REF="$COMMIT_HASH" --build-arg BASEIMAGE="clelange/$BASE_IMAGE-cms:latest" --build-arg SCRAM_ARCH="$SCRAM_ARCH" --build-arg CMSSW_VERSION="$CMSSW_VERSION"
build cms cvmfs:
stage: build
only:
variables:
- $CI_PIPELINE_SOURCE == "pipeline" && $IMAGE_NAME
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- echo "Building image for $IMAGE_NAME"
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR/$IMAGE_NAME --dockerfile $CI_PROJECT_DIR/$IMAGE_NAME/Dockerfile --destination $CI_REGISTRY_IMAGE/$IMAGE_NAME:$DATE-$COMMIT_HASH --destination $CI_REGISTRY_IMAGE/$IMAGE_NAME:latest --build-arg=BUILD_DATE="$DATE" --build-arg=VERSION="$DATE" --build-arg=VCS_URL="$CI_REPOSITORY_URL" --build-arg=VCS_REF="$COMMIT_HASH"
#!/bin/bash
files=$(git diff-tree --no-commit-id --name-only -r $CI_COMMIT_SHA)
for file in $files; do
dir=${file%/*}
curl --request POST \
--form token=$CI_JOB_TOKEN \
--form ref=$CI_DEFAULT_BRANCH \
--form "variables[IMAGE_NAME]=$dir" \
https://gitlab.cern.ch/api/v4/projects/$CI_PROJECT_ID/trigger/pipeline
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment