From: Jessica Wagantall Date: Thu, 30 May 2019 00:43:45 +0000 (-0700) Subject: Update lf-docker-jobs to enforce macro vars X-Git-Tag: v0.38.1~1 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=5113d3c9d84c3e4237e3c2fa0f616bdfcb2a6d15;p=releng%2Fglobal-jjb.git Update lf-docker-jobs to enforce macro vars 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 --- diff --git a/.jjb-test/lf-docker-jobs/docker-jobs.yaml b/.jjb-test/lf-docker-jobs/docker-jobs.yaml index bb05ea4b..a414ab99 100644 --- a/.jjb-test/lf-docker-jobs/docker-jobs.yaml +++ b/.jjb-test/lf-docker-jobs/docker-jobs.yaml @@ -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 diff --git a/jjb/lf-docker-jobs.yaml b/jjb/lf-docker-jobs.yaml index 0de21fb2..220c2252 100644 --- a/jjb/lf-docker-jobs.yaml +++ b/jjb/lf-docker-jobs.yaml @@ -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: '' @@ -131,8 +135,14 @@ 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 @@ -161,11 +171,18 @@ 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 index 00000000..c7fdc362 --- /dev/null +++ b/releasenotes/notes/lf-docker-jobs-fix-variables-2575c6047e5b62cf.yaml @@ -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.