Skip to content

Commit

Permalink
Make jenkins pipeline to use robot account credentials (dmwm#7094)
Browse files Browse the repository at this point in the history
  • Loading branch information
novicecpp authored Feb 25, 2022
1 parent 4bd7e24 commit 3ac0a3a
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions cicd/build/jenkins_build_docker.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

set -euo pipefail
set -x

echo "(DEBUG) variables from upstream jenkin job (CRABServer_BuildImage_20220127):"
echo "(DEBUG) \- BRANCH: ${BRANCH}"
echo "(DEBUG) \- RELEASE_TAG: ${RELEASE_TAG}"
Expand All @@ -8,21 +11,28 @@ echo "(DEBUG) jenkin job's env variables:"
echo "(DEBUG) \- WORKSPACE: $WORKSPACE"
echo "(DEBUG) end"

# use docker config on our WORKSPACE area, avoid replace default creds in ~/.docker that many pipeline depend on it
export DOCKER_CONFIG=$PWD/docker_login

#build and push crabtaskworker image
git clone https://github.com/dmwm/CRABServer.git
cd CRABServer/Docker

#replace where RPMs are stored
sed -i.bak -e "/export REPO=*/c\export REPO=comp.crab_${BRANCH}" install.sh
echo "(DEBUG) diff dmwm/CRABServer/Docker/install.sh"
diff -u install.sh.bak install.sh
ls .
diff -u install.sh.bak install.sh || true
echo "(DEBUG) end"

docker build . -t cmssw/crabtaskworker:${RELEASE_TAG} --network=host \
# use cmscrab robot account credentials
docker login registry.cern.ch --username $HARBOR_CMSCRAB_USERNAME --password-stdin <<< $HARBOR_CMSCRAB_PASSWORD

docker build . -t registry.cern.ch/cmscrab/crabtaskworker:${RELEASE_TAG} --network=host \
--build-arg RELEASE_TAG=${RELEASE_TAG} \
--build-arg RPM_RELEASETAG_HASH=${RPM_RELEASETAG_HASH}
docker push cmssw/crabtaskworker:${RELEASE_TAG}
docker rmi cmssw/crabtaskworker:${RELEASE_TAG}
docker push registry.cern.ch/cmscrab/crabtaskworker:${RELEASE_TAG}
docker rmi registry.cern.ch/cmscrab/crabtaskworker:${RELEASE_TAG}

#build and push crabserver image
cd $WORKSPACE
Expand All @@ -33,7 +43,9 @@ cd CMSKubernetes/docker/
HGVERSION=$(curl -s "http://cmsrep.cern.ch/cmssw/repos/comp.crab_${BRANCH}/slc7_amd64_gcc630/latest/RPMS.json" | grep -oP 'HG\d{4}(.*)(?=":)' | head -1)
sed -i.bak -e "/REPO=\"comp*/c\REPO=\"comp.crab_${BRANCH}\"" -e "s/VER=HG.*/VER=$HGVERSION/g" -- crabserver/install.sh
echo "(DEBUG) diff dmwm/CMSKubernetes/docker/crabserver/install.sh"
diff -u crabserver/install.sh.bak crabserver/install.sh
diff -u crabserver/install.sh.bak crabserver/install.sh || true
echo "(DEBUG) end"

# relogin to using cmsweb robot account
docker login registry.cern.ch --username $HARBOR_CMSWEB_USERNAME --password-stdin <<< $HARBOR_CMSWEB_PASSWORD
CMSK8STAG=${RELEASE_TAG} ./build.sh "crabserver"

0 comments on commit 3ac0a3a

Please sign in to comment.