Allow GERRIT_* variables to be overridden manually in the docker-publish job
Change-Id: Iee6ec5779f15c9eb7d703b7a7ed38783b4fa0a1a
diff --git a/jjb/docker-publish.yaml b/jjb/docker-publish.yaml
index 1c7d190..8315872 100644
--- a/jjb/docker-publish.yaml
+++ b/jjb/docker-publish.yaml
@@ -42,6 +42,16 @@
description: 'git ref to build (commit hash or tag)'
- string:
+ name: projectName
+ default: '$GERRIT_PROJECT'
+ description: 'Name of the project in Gerrit'
+
+ - string:
+ name: branchName
+ default: '$GERRIT_BRANCH'
+ description: 'Branch of the project in Gerrit'
+
+ - string:
name: dockerRepo
default: '{docker-repo}'
description: "Docker repository to push to ('opencord', 'xosproject', etc.)"
diff --git a/jjb/pipeline/docker-publish.groovy b/jjb/pipeline/docker-publish.groovy
index e9f05a3..9279635 100644
--- a/jjb/pipeline/docker-publish.groovy
+++ b/jjb/pipeline/docker-publish.groovy
@@ -17,12 +17,12 @@
]],
extensions: [
[$class: 'WipeWorkspace'],
- [$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.GERRIT_PROJECT}"],
+ [$class: 'RelativeTargetDirectory', relativeTargetDir: "${params.projectName}"],
[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
],
])
script {
- git_tags = sh(script:"cd $GERRIT_PROJECT; git tag -l --points-at HEAD", returnStdout: true).trim()
+ git_tags = sh(script:"cd $projectName; git tag -l --points-at HEAD", returnStdout: true).trim()
}
}
}
@@ -34,7 +34,7 @@
set -eu -o pipefail
# checked out in a subdir so the log can be in WORKSPACE
- cd "$GERRIT_PROJECT"
+ cd "$projectName"
# set registry/repository variables
export DOCKER_REGISTRY="$dockerRegistry"
@@ -42,7 +42,7 @@
# Build w/branch
echo "Building image with branch"
- make DOCKER_TAG="$GERRIT_BRANCH" docker-build 2>&1 | tee "$WORKSPACE/docker-build.log"
+ make DOCKER_TAG="$branchName" docker-build 2>&1 | tee "$WORKSPACE/docker-build.log"
# Build w/tags if they exist
if [ -n "$git_tags" ]
@@ -69,7 +69,7 @@
set -eu -o pipefail
# checked out in a subdir so the log can be in WORKSPACE
- cd "$GERRIT_PROJECT"
+ cd "$projectName"
# set registry/repository variables
export DOCKER_REGISTRY="$dockerRegistry"
@@ -77,7 +77,7 @@
# Push w/branch
echo "Pushing image with branch"
- make DOCKER_TAG="$GERRIT_BRANCH" docker-push 2>&1 | tee "$WORKSPACE/docker-push.log"
+ make DOCKER_TAG="$branchName" docker-push 2>&1 | tee "$WORKSPACE/docker-push.log"
# Push w/tags if they exist
if [ -n "$git_tags" ]