Update lf-docker-jobs to enforce macro vars 90/15790/3
authorJessica Wagantall <jwagantall@linuxfoundation.org>
Thu, 30 May 2019 00:43:45 +0000 (17:43 -0700)
committerJessica Wagantall <jwagantall@linuxfoundation.org>
Thu, 30 May 2019 19:03:33 +0000 (12:03 -0700)
Enforce the variables from "lf-docker-get-container-tag",
"lf-docker-build" and "lf-docker-push" to be carried over
when calling the macros. This avoids the issue of loosing
the value of the variables.
Update the test file to reflect the example better.

Change-Id: I5087b6fbd064d145fab4be8dad72ff196fdfa213
Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
.jjb-test/lf-docker-jobs/docker-jobs.yaml
jjb/lf-docker-jobs.yaml
releasenotes/notes/lf-docker-jobs-fix-variables-2575c6047e5b62cf.yaml [new file with mode: 0644]

index bb05ea4..a414ab9 100644 (file)
@@ -7,7 +7,10 @@
     project: docker/project
     project-name: docker-project
     container-public-registry: pub-registry
-    container-snapshot-registry: snap-registry
+    container-push-registry: push-registry
+    docker-build-args: ''
     docker-name: docker-image-name
+    docker-root: docker
+    docker-use-params-from: yaml-file-params
     branch: master
     mvn-settings: docker-project-settings
index 0de21fb..220c225 100644 (file)
@@ -8,6 +8,10 @@
 - builder:
     name: lf-docker-get-container-tag
     builders:
+      - inject:
+          properties-content: |
+            DOCKER_NAME={docker-name}
+            DOCKER_ROOT={docker-root}
       - conditional-step:
           condition-kind: regex-match
           regex: git-describe-params
@@ -33,7 +37,6 @@
       - inject:
           properties-content: |
             DOCKER_ARGS={docker-build-args}
-            DOCKER_NAME={docker-name}
             DOCKER_ROOT={docker-root}
             CONTAINER_PULL_REGISTRY={container-public-registry}
       - shell: !include-raw-escape:
@@ -68,8 +71,9 @@
     submodule-disable: false
     submodule-recursive: true
     submodule-timeout: 10
-    pre_docker_build_script: ''
-    post_docker_build_script: ''
+    pre_docker_build_script: '# pre docker build script goes here'
+    post_docker_build_script: '# post docker build script goes here'
+    docker-use-params-from: ''
     disable-job: 'false'
     docker-root: '$WORKSPACE'
     docker-build-args: ''
           global-settings-file: 'global-settings'
           settings-file: '{mvn-settings}'
       - shell: '{pre_docker_build_script}'
-      - lf-docker-get-container-tag
-      - lf-docker-build
+      - lf-docker-get-container-tag:
+          docker-use-params-from: '{docker-use-params-from}'
+          docker-name: '{docker-name}'
+          docker-root: '{docker-root}'
+      - lf-docker-build:
+          docker-build-args: '{docker-build-args}'
+          docker-root: '{docker-root}'
+          container-public-registry: '{container-public-registry}'
       - shell: '{post_docker_build_script}'
       - lf-provide-maven-settings-cleanup
 
           global-settings-file: 'global-settings'
           settings-file: '{mvn-settings}'
       - shell: '{pre_docker_build_script}'
-      - lf-docker-get-container-tag
-      - lf-docker-build
+      - lf-docker-get-container-tag:
+          docker-use-params-from: '{docker-use-params-from}'
+          docker-name: '{docker-name}'
+          docker-root: '{docker-root}'
+      - lf-docker-build:
+          docker-build-args: '{docker-build-args}'
+          docker-root: '{docker-root}'
+          container-public-registry: '{container-public-registry}'
       - shell: '{post_docker_build_script}'
       # Provided all steps have already passed, push the docker image
-      - lf-docker-push
+      - lf-docker-push:
+          container-push-registry: '{container-push-registry}'
       - lf-provide-maven-settings-cleanup
 
 #################
diff --git a/releasenotes/notes/lf-docker-jobs-fix-variables-2575c6047e5b62cf.yaml b/releasenotes/notes/lf-docker-jobs-fix-variables-2575c6047e5b62cf.yaml
new file mode 100644 (file)
index 0000000..c7fdc36
--- /dev/null
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    When calling builder step macros "lf-docker-get-container-tag",
+    "lf-docker-build" and "lf-docker-push", make sure the needed variables
+    are also passed explicitly to avoid these variables appear as undefined.