Add DRY_RUN param to the release job 20/16720/5
authorAnil Belur <abelur@linuxfoundation.org>
Wed, 28 Aug 2019 18:02:03 +0000 (23:32 +0530)
committerAric Gardner <agardner@linuxfoundation.org>
Wed, 28 Aug 2019 18:17:22 +0000 (14:17 -0400)
Add DRY_RUN build param to do a test run the job with
publishing artifacts.

Change-Id: I1b015db4be8ed3e8c39bec2cefe022819e31e59f
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
docs/jjb/lf-release-jobs.rst
jjb/lf-release-jobs.yaml
releasenotes/notes/fix-release-job-script-4309fdf6b2897370.yaml [new file with mode: 0644]
shell/release-job.sh

index a2cfd95..dddaac3 100644 (file)
@@ -8,8 +8,12 @@ Self serve release jobs allow a project to create a releases/ or .releases/ dire
 Jenkins will pick this up and sign the ref extrapolated by log_dir and promote the artifact, whether maven or container.
 
 Maven release jobs can also trigger via "Build with parameters" negating the need for a release file.
-The parameters will need to be filled out in the same was as a release file's would, excepting the speacial
-USE_RELEASE_FILE parameter which will need to be set to False to inform the job that it should not expect a release file.
+The parameters will need to be filled out in the same was as a release file's would, excepting the special
+USE_RELEASE_FILE and DRY_RUN check boxes. The USE_RELEASE_FILE check box will need to be unchecked, if the job
+is expected to run with a release file, while passing the required information as build parameters.
+Similarly, the DRY_RUN check box will need to be unchecked, if the job needs to be tested while skipping
+repository promotion to Nexus.
+
 The Special Parameters are as follows:
 
 GERRIT_BRANCH = master
@@ -17,6 +21,7 @@ VERSION = 1.0.0
 LOG_DIR = example-project-maven-stage-master/17/
 DISTRIBUTION_TYPE = maven
 USE_RELEASE_FILE = false
+DRY_RUN = false
 
 .. note::
 
index 200b14b..fbef3fa 100644 (file)
       - lf-infra-properties:
           build-days-to-keep: 7
 
-    parameters:
-      - lf-infra-parameters:
-          project: "{project}"
-          branch: "$GERRIT_BRANCH"
-          stream: "$GERRIT_BRANCH"
-      - lf-build-with-parameters-maven-release:
-          use-release-file: "{use-release-file}"
-
     publishers:
       - lf-infra-publish
 
 
     disabled: "{disable-job}"
 
+    parameters:
+      - lf-infra-parameters:
+          project: "{project}"
+          branch: "$GERRIT_BRANCH"
+          stream: "$GERRIT_BRANCH"
+      - lf-build-with-parameters-maven-release:
+          use-release-file: "{use-release-file}"
+
     builders:
       - lf-infra-pre-build
       - conditional-step:
 
     disabled: "{disable-job}"
 
+    parameters:
+      - lf-infra-parameters:
+          project: "{project}"
+          branch: "$GERRIT_BRANCH"
+          stream: "$GERRIT_BRANCH"
+      - lf-build-with-parameters-maven-release:
+          use-release-file: "{use-release-file}"
+      - bool:
+          name: DRY_RUN
+          default: false
+          description: |
+            If DRY_RUN is enabled artifacts are not published.
+
     builders:
       - lf-infra-pre-build
       - conditional-step:
diff --git a/releasenotes/notes/fix-release-job-script-4309fdf6b2897370.yaml b/releasenotes/notes/fix-release-job-script-4309fdf6b2897370.yaml
new file mode 100644 (file)
index 0000000..18aa5b3
--- /dev/null
@@ -0,0 +1,4 @@
+---
+features:
+  - |
+    Add DRY_RUN build param to do a test run the job with publishing artifacts.
index 3a36a57..fd43d75 100644 (file)
@@ -51,7 +51,7 @@ tag(){
     echo "git tag -v $VERSION"
     git tag -v "$VERSION"
     ########## Merge Part ##############
-    if [[ "$JOB_NAME" =~ "merge" ]]; then
+    if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then
       echo "--> INFO: Running merge"
       gerrit_ssh=$(echo "$GERRIT_URL" | awk -F"/" '{print $3}')
       git remote set-url origin ssh://"$RELEASE_USERNAME"@"$gerrit_ssh":29418/"$PROJECT"
@@ -76,9 +76,9 @@ nexus_release(){
     echo "Merge will run"
     echo "lftools nexus release --server https://$NEXUS_URL $STAGING_REPO"
   done
-  #Run the loop twice, to catch errors on either nexus repo
 
-  if [[ "$JOB_NAME" =~ "merge" ]]; then
+  #Run the loop twice, to catch errors on either nexus repo
+  if [[ "$JOB_NAME" =~ "merge" ]] && [[ "$DRY_RUN" = false ]]; then
     for staging_url in $(zcat "$PATCH_DIR"/staging-repo.txt.gz | awk -e '{print $2}'); do
       NEXUS_URL=$(echo "$staging_url" | sed -e 's|^[^/]*//||' -e 's|/.*$||')
       STAGING_REPO=${staging_url#*repositories/}
@@ -118,8 +118,8 @@ container_release_file(){
       echo "docker tag $container_image_id $DOCKER_REGISTRY:10002/$lfn_umbrella/$name:$VERSION"
       echo "docker push $DOCKER_REGISTRY:10002/$lfn_umbrella/$name:$VERSION"
       if [[ "$JOB_NAME" =~ "merge" ]]; then
-      docker tag "$container_image_id" "$DOCKER_REGISTRY":10002/"$lfn_umbrella"/"$name":"$VERSION"
-      docker push "$DOCKER_REGISTRY":10002/"$lfn_umbrella"/"$name":"$VERSION"
+        docker tag "$container_image_id" "$DOCKER_REGISTRY":10002/"$lfn_umbrella"/"$name":"$VERSION"
+        docker push "$DOCKER_REGISTRY":10002/"$lfn_umbrella"/"$name":"$VERSION"
       fi
       echo "#########################"
     fi