From: Thanh Ha Date: Fri, 11 Aug 2017 21:26:32 +0000 (-0400) Subject: Refactor packer ci templates X-Git-Tag: v0.7.0~8^2~1 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=a04838d4bda17003bd5407e77d9b7d5df62fd5b0;p=releng%2Fglobal-jjb.git Refactor packer ci templates Improve maintainability by refactoring some common code. - Improve documentation - Reorganize anchors for better maintainability - Remove dependency on jjb_common anchor (updates to jjb code should not not break packer code) - Do not run packer merge jobs concurrently (merge jobs should not be configured to run concurrently) Change-Id: Ib796cfee44ae7b01b42ee400a04be79b243cac3b Signed-off-by: Thanh Ha --- diff --git a/jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-java-builder b/jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-java-builder index 869ba6d8..730f5280 100644 --- a/jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-java-builder +++ b/jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-java-builder @@ -5,7 +5,7 @@ false false false - true + false build-vm false diff --git a/jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-mininet b/jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-mininet index bcfd8910..367f17d8 100644 --- a/jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-mininet +++ b/jjb-test/expected-xml/gerrit-ciman-packer-merge-centos-mininet @@ -5,7 +5,7 @@ false false false - true + false build-vm false diff --git a/jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-java-builder b/jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-java-builder index 4e2eaebc..27466db0 100644 --- a/jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-java-builder +++ b/jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-java-builder @@ -5,7 +5,7 @@ false false false - true + false build-vm false diff --git a/jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-mininet b/jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-mininet index 97ccd566..a62d8776 100644 --- a/jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-mininet +++ b/jjb-test/expected-xml/gerrit-ciman-packer-merge-ubuntu1604-mininet @@ -5,7 +5,7 @@ false false false - true + false build-vm false diff --git a/jjb-test/expected-xml/github-ciman-packer-merge-centos-java-builder b/jjb-test/expected-xml/github-ciman-packer-merge-centos-java-builder index 2f044d9c..699ac5d4 100644 --- a/jjb-test/expected-xml/github-ciman-packer-merge-centos-java-builder +++ b/jjb-test/expected-xml/github-ciman-packer-merge-centos-java-builder @@ -5,7 +5,7 @@ false false false - true + false build-vm false diff --git a/jjb-test/expected-xml/github-ciman-packer-merge-centos-mininet b/jjb-test/expected-xml/github-ciman-packer-merge-centos-mininet index a2b2c665..64a5a7c0 100644 --- a/jjb-test/expected-xml/github-ciman-packer-merge-centos-mininet +++ b/jjb-test/expected-xml/github-ciman-packer-merge-centos-mininet @@ -5,7 +5,7 @@ false false false - true + false build-vm false diff --git a/jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-java-builder b/jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-java-builder index e734f840..719709ca 100644 --- a/jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-java-builder +++ b/jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-java-builder @@ -5,7 +5,7 @@ false false false - true + false build-vm false diff --git a/jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-mininet b/jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-mininet index ce8a79e7..cac1b63f 100644 --- a/jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-mininet +++ b/jjb-test/expected-xml/github-ciman-packer-merge-ubuntu1604-mininet @@ -5,7 +5,7 @@ false false false - true + false build-vm false diff --git a/jjb/lf-ci-jobs.yaml b/jjb/lf-ci-jobs.yaml index 37467a55..ef8c665f 100644 --- a/jjb/lf-ci-jobs.yaml +++ b/jjb/lf-ci-jobs.yaml @@ -76,19 +76,29 @@ - lf_packer: &lf_packer_common name: lf-packer-common - # Adds wrappers and parameters sections common to packer jobs. + # Provide configuration common in packer jobs. ###################### # Default parameters # ###################### + branch: master build-timeout: 45 + stream: master + submodule-recursive: true packer-cloud-settings: packer-cloud-env - wrappers: - - lf-infra-wrappers: - build-timeout: '{build-timeout}' - jenkins-ssh-credential: '{jenkins-ssh-credential}' + ##################### + # Job Configuration # + ##################### + + project-type: freestyle + node: '{build-node}' + + properties: + - lf-infra-properties: + project: '{project}' + build-days-to-keep: 7 parameters: - lf-infra-parameters: @@ -98,6 +108,14 @@ - lf-infra-packer-parameters: packer-version: '{packer-version}' + wrappers: + - lf-infra-wrappers: + build-timeout: '{build-timeout}' + jenkins-ssh-credential: '{jenkins-ssh-credential}' + + publishers: + - lf-infra-publish + - parameter: name: lf-infra-jjb-parameters parameters: @@ -404,17 +422,54 @@ # Packer Merge # ################ -- lf_packer_merge_builders: &lf_packer_merge_builders - name: lf-packer-merge-builders +- lf_packer_merge: &lf_packer_merge + name: lf-packer-merge - # Adds builders section common to merge packer jobs. - # {packer-cloud-settings} is passed from the project, defines the managed - # file-id name created in Jenkins - # (default: packer-cloud-env) - # {packer-version}: is global defined in job group level, the version number - # can be updated to install the latest version of packer. - # {platforms}: defines the packer platform file, passed from the project. - # {template}: defines the packer template file, passed from the project. + # Packer Merge job runs `packer build` to build system images in the cloud. + # + # Required parameters: + # + # :build-node: The node to run build on. + # :jenkins-ssh-credential: Credential to use for SSH. (Generally should + # be configured in defaults.yaml) + # :mvn-settings: The name of settings file containing credentials for + # the project. + # :platforms: Platform or distribution to build. Typically json file + # found in the packer/vars directory. (Example: centos) + # :template: System template to build. Typically shell script found in + # the packer/provision directory. (Example: java-builder) + # + # Optional parameters: + # + # :branch: Git branch to fetch for the build. (default: master) + # :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7) + # :build-timeout: Timeout in seconds before aborting build. (default: 10) + # :git-url: URL clone project from. (default: $GIT_URL/$PROJECT) + # :packer-cloud-settings: Name of settings file containing credentials + # for the cloud that packer will build on. (default: packer-cloud-env) + # :packer-version: Version of packer to install / use in build. (default: 1.0.2) + # :stream: Keyword that can be used to represent a release code-name. + # Often the same as the branch. (default: master) + # :submodule-recursive: Whether to checkout submodules recursively. + # (default: true) + # + # :gerrit_verify_triggers: Override Gerrit Triggers. + # :gerrit_trigger_file_paths: Override file paths which can be used to + # filter which file modifications will trigger a build. + # (default defined by lf_jjb_common) + + ###################### + # Default parameters # + ###################### + + gerrit_merge_triggers: + - change-merged-event + - comment-added-contains-event: + comment-contains-value: remerge$ + + ##################### + # Job Configuration # + ##################### builders: - lf-infra-packer-validate: @@ -429,28 +484,12 @@ - job-template: name: '{project-name}-packer-merge-{platforms}-{templates}' id: gerrit-packer-merge - concurrent: true - <<: *lf_jjb_common - # yamllint disable-line rule:key-duplicates <<: *lf_packer_common # yamllint disable-line rule:key-duplicates - <<: *lf_packer_merge_builders - - ###################### - # Default parameters # - ###################### + <<: *lf_packer_merge git-url: '$GIT_URL/$GERRIT_PROJECT' - gerrit_merge_triggers: - - change-merged-event - - comment-added-contains-event: - comment-contains-value: remerge$ - - ##################### - # Job Configuration # - ##################### - scm: - lf-infra-gerrit-scm: git-url: '{git-url}' @@ -476,16 +515,9 @@ - job-template: name: '{project-name}-packer-merge-{platforms}-{templates}' id: github-packer-merge - concurrent: true - <<: *lf_jjb_common - # yamllint disable-line rule:key-duplicates <<: *lf_packer_common # yamllint disable-line rule:key-duplicates - <<: *lf_packer_merge_builders - - ##################### - # Job Configuration # - ##################### + <<: *lf_packer_merge properties: - github: @@ -519,37 +551,43 @@ # Packer Verify # ################# -- lf_packer_verify_builders: &lf_packer_verify_builders - name: lf-packer-verify-builders - - # Adds builders section common to verify packer jobs. - # {packer-cloud-settings} is passed from the project, defines the managed - # file-id name created in Jenkins - # (default: packer-cloud-env) - # {packer-version}: is global defined in job group level, the version number - # can be updated to install the latest version of packer. +- lf_packer_verify: &lf_packer_verify + name: lf-packer-verify - builders: - - lf-infra-packer-validate: - packer-cloud-settings: '{packer-cloud-settings}' - packer-version: '{packer-version}' - -- job-template: - name: '{project-name}-packer-verify' - id: gerrit-packer-verify - concurrent: true - <<: *lf_jjb_common - # yamllint disable-line rule:key-duplicates - <<: *lf_packer_common - # yamllint disable-line rule:key-duplicates - <<: *lf_packer_verify_builders + # Packer Verify job runs `packer validate` to verify packer configuration. + # + # Required parameters: + # + # :build-node: The node to run build on. + # :jenkins-ssh-credential: Credential to use for SSH. (Generally should + # be configured in defaults.yaml) + # :mvn-settings: The name of settings file containing credentials for + # the project. + # + # Optional parameters: + # + # :branch: Git branch to fetch for the build. (default: master) + # :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7) + # :build-timeout: Timeout in seconds before aborting build. (default: 10) + # :git-url: URL clone project from. (default: $GIT_URL/$PROJECT) + # :packer-cloud-settings: Name of settings file containing credentials + # for the cloud that packer will build on. (default: packer-cloud-env) + # :packer-version: Version of packer to install / use in build. (default: 1.0.2) + # :stream: Keyword that can be used to represent a release code-name. + # Often the same as the branch. (default: master) + # :submodule-recursive: Whether to checkout submodules recursively. + # (default: true) + # + # :gerrit_verify_triggers: Override Gerrit Triggers. + # :gerrit_trigger_file_paths: Override file paths which can be used to + # filter which file modifications will trigger a build. + # (default defined by lf_jjb_common) ###################### # Default parameters # ###################### build-timeout: 10 - git-url: '$GIT_URL/$GERRIT_PROJECT' gerrit_verify_triggers: - patchset-created-event: @@ -564,6 +602,22 @@ # Job Configuration # ##################### + concurrent: true + + builders: + - lf-infra-packer-validate: + packer-cloud-settings: '{packer-cloud-settings}' + packer-version: '{packer-version}' + +- job-template: + name: '{project-name}-packer-verify' + id: gerrit-packer-verify + <<: *lf_packer_common + # yamllint disable-line rule:key-duplicates + <<: *lf_packer_verify + + git-url: '$GIT_URL/$GERRIT_PROJECT' + scm: - lf-infra-gerrit-scm: git-url: '{git-url}' @@ -588,22 +642,9 @@ - job-template: name: '{project-name}-packer-verify' id: github-packer-verify - concurrent: true - <<: *lf_jjb_common - # yamllint disable-line rule:key-duplicates <<: *lf_packer_common # yamllint disable-line rule:key-duplicates - <<: *lf_packer_verify_builders - - ###################### - # Default parameters # - ###################### - - build-timeout: 10 - - ##################### - # Job Configuration # - ##################### + <<: *lf_packer_verify properties: - github: