Commit 955a1503 authored by Clemens Lange's avatar Clemens Lange
Browse files

Merge branch 'ci' into 'master'

CI for image building

Closes #16

See merge request cms-cloud/cmssw-docker!13
parents 8420e087 bff0f777
......@@ -5,52 +5,48 @@ stages:
before_script:
- export DATE=$(date +"%Y-%m-%d")
variables:
COMMIT_HASH: $CI_COMMIT_SHORT_SHA
check_changed_files:
stage: check
only:
variables:
- $CI_PIPELINE_SOURCE == 'push'
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_template: &build_cms_cvmfs
.build_image_template: &build_image
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- echo "Building image for $IMAGE_NAME"
- echo "Pipeline source - $CI_PIPELINE_SOURCE"
- echo "Building image - $IMAGE_NAME"
- printf "Release - $RELEASE\nScram Arch - $SCRAM_ARCH\nBase image - $BASE_IMAGE\n"
- 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"
- /kaniko/executor --context $CI_PROJECT_DIR/$REPO_NAME --dockerfile $CI_PROJECT_DIR/$REPO_NAME/Dockerfile --destination $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG --build-arg=BUILD_DATE="$DATE" --build-arg=VERSION="$DATE" --build-arg=VCS_URL="$CI_REPOSITORY_URL" --build-arg=VCS_REF="$CI_COMMIT_SHORT_SHA" --build-arg BASEIMAGE="$BASE_IMAGE" --build-arg SCRAM_ARCH="$SCRAM_ARCH" --build-arg CMSSW_VERSION="$RELEASE"
build_cms_cvmfs_pipeline:
<<: *build_cms_cvmfs
<<: *build_image
stage: build
only:
variables:
- $IMAGE_NAME
variables:
REPO_NAME: $IMAGE_NAME
IMAGE_TAG: $DATE-$CI_COMMIT_SHORT_SHA
build_standalone_pipeline:
<<: *build_image
stage: build
only:
variables:
- $RELEASE && $SCRAM_ARCH && $OS
tags:
- docker-privileged-xl
variables:
IMAGE_NAME: cmssw
REPO_NAME: standalone
IMAGE_TAG: $RELEASE-$SCRAM_ARCH-$DATE-$CI_COMMIT_SHORT_SHA
BASE_IMAGE: "clelange/$OS-cms:latest"
\ No newline at end of file
......@@ -4,9 +4,16 @@ 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
echo "Changes in $dir directory"
if [[ "$dir" =~ ^(cc7-cms|cc7-cvmfs|slc6-cms|slc6-cvmfs|slc5-cms)$ ]]; then
echo "Triggered build of $dir"
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
fi
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