Reorganize template definition structure 43/5843/2
authorThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 11 Aug 2017 02:48:56 +0000 (22:48 -0400)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 11 Aug 2017 03:43:01 +0000 (23:43 -0400)
Having maintained this repo for awhile we can now see some common
patterns emerge from our yaml structures. Typically for a given job
there is a common builder anchor followed by 2 template sections, 1
for Gerrit and 1 for GitHub. Plus some common macros / anchors that
may be used by multiple job types.

This patch reorganizes the structure to treat a set of
anchor-gerrit-github job definitions as a single job definition. This
allows us to keep the job template close to their anchor definition so
that looking up what the main anchor does will not cause as much back
scroll.

Additionally this patch refactors the confusingly named verify_merge
anchors to a more understandable 'common' name.

Change-Id: I95eb4609274ec21b50aef059b03ac4598894f671
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
jjb/lf-ci-jobs.yaml
jjb/lf-maven-jobs.yaml
jjb/lf-python-jobs.yaml

index c130f26..add785f 100644 (file)
@@ -49,9 +49,8 @@
       - github-packer-merge
       - github-packer-verify
 
-
 ####################
-# Anchors & Macros #
+# COMMON FUNCTIONS #
 ####################
 
 - builder:
       - compare-type: ANT
         pattern: 'packer/provision/lib/**'
 
-- lf_jjb_merge_builders: &lf_jjb_merge_builders
-    name: lf-jjb-merge-builders
-    builders:
-      - lf-infra-jjbini
-      - shell: !include-raw-escape:
-          - ../shell/jjb-install.sh
-          - ../shell/jjb-merge-job.sh
-
-- lf_jjb_verify_builders: &lf_jjb_verify_builders
-    name: lf-jjb-verfy-builders
-    builders:
-      - lf-infra-jjbini
-      - shell: !include-raw-escape:
-          - ../shell/git-validate-jira-urls.sh
-          - ../shell/jjb-install.sh
-          - ../shell/jjb-verify-job.sh
-          - ../shell/jjb-check-unicode.sh
-      - lf-infra-gpg-verify-git-signature
-
 - lf_packer: &lf_packer_common
     name: lf-packer-common
     # Adds wrappers and parameters sections common to packer jobs.
       - lf-infra-packer-parameters:
           packer-version: '{packer-version}'
 
-- lf_packer_merge_builders: &lf_packer_merge_builders
-    name: lf-packer-merge-builders
-    # 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.
-    builders:
-      - lf-infra-packer-validate:
-          packer-cloud-settings: '{packer-cloud-settings}'
-          packer-version: '{packer-version}'
-      - lf-infra-packer-build:
-          packer-cloud-settings: '{packer-cloud-settings}'
-          packer-version: '{packer-version}'
-          platform: '{platforms}'
-          template: '{templates}'
-
-- lf_packer_verify_builders: &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.
-    name: lf-packer-verify-builders
-    builders:
-      - lf-infra-packer-validate:
-          packer-cloud-settings: '{packer-cloud-settings}'
-          packer-version: '{packer-version}'
-
 - parameter:
     name: lf-infra-jjb-parameters
     parameters:
           default: '{packer-version}'
           description: Packer version to download and install.
 
-
-#################
-# Job Templates #
-#################
-
-# JJB verify and merge jobs are the same except for their scm, trigger, and
-# builders definition. This anchor is the common template
-- lf_jjb_verify_merge: &lf_jjb_verify_merge
-    name: lf-jjb-verify-merge
+- lf_jjb_common: &lf_jjb_common
+    name: lf-jjb-common
     project-type: freestyle
 
     node: '{build-node}'
     publishers:
       - lf-infra-publish
 
+#############
+# JJB Merge #
+#############
+
+- lf_jjb_merge_builders: &lf_jjb_merge_builders
+    name: lf-jjb-merge-builders
+    builders:
+      - lf-infra-jjbini
+      - shell: !include-raw-escape:
+          - ../shell/jjb-install.sh
+          - ../shell/jjb-merge-job.sh
+
 - job-template:
     name: '{project-name}-jjb-merge'
     id: gerrit-jjb-merge
-    <<: *lf_jjb_verify_merge
+    <<: *lf_jjb_common
     # yamllint disable-line rule:key-duplicates
     <<: *lf_jjb_merge_builders
 
                   branch-pattern: '**/{branch}'
               <<: *lf_jjb_file_paths
 
+- job-template:
+    name: '{project-name}-jjb-merge'
+    id: github-jjb-merge
+    <<: *lf_jjb_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_jjb_merge_builders
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    properties:
+      - github:
+          url: '{git-url}/{github-org}/{project}'
+
+    scm:
+      - lf-infra-github-scm:
+          url: '{git-clone-url}{github-org}/{project}'
+          refspec: ''
+          branch: '{branch}'
+          submodule-recursive: '{submodule-recursive}'
+          choosing-strategy: default
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    triggers:
+      - github
+      - pollscm:
+          cron: ''
+      - lf-infra-github-pr-trigger:
+          trigger-phrase: '^remerge$'
+          only-trigger-phrase: true
+          status-context: 'JJB Merge'
+          permit-all: false
+          github-hooks: true
+          github-org: '{github-org}'
+          github_pr_whitelist: '{obj:github_pr_whitelist}'
+          github_pr_admin_list: '{obj:github_pr_admin_list}'
+
+##############
+# JJB Verify #
+##############
+
+- lf_jjb_verify_builders: &lf_jjb_verify_builders
+    name: lf-jjb-verfy-builders
+    builders:
+      - lf-infra-jjbini
+      - shell: !include-raw-escape:
+          - ../shell/git-validate-jira-urls.sh
+          - ../shell/jjb-install.sh
+          - ../shell/jjb-verify-job.sh
+          - ../shell/jjb-check-unicode.sh
+      - lf-infra-gpg-verify-git-signature
+
 - job-template:
     name: '{project-name}-jjb-verify'
     id: gerrit-jjb-verify
     concurrent: true
-    <<: *lf_jjb_verify_merge
+    <<: *lf_jjb_common
     # yamllint disable-line rule:key-duplicates
     <<: *lf_jjb_verify_builders
 
                   branch-pattern: '**/{branch}'
               <<: *lf_jjb_file_paths
 
-- job-template:
-    name: '{project-name}-jjb-merge'
-    id: github-jjb-merge
-    <<: *lf_jjb_verify_merge
-    # yamllint disable-line rule:key-duplicates
-    <<: *lf_jjb_merge_builders
-
-    #####################
-    # Job Configuration #
-    #####################
-
-    properties:
-      - github:
-          url: '{git-url}/{github-org}/{project}'
-
-    scm:
-      - lf-infra-github-scm:
-          url: '{git-clone-url}{github-org}/{project}'
-          refspec: ''
-          branch: '{branch}'
-          submodule-recursive: '{submodule-recursive}'
-          choosing-strategy: default
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-
-    triggers:
-      - github
-      - pollscm:
-          cron: ''
-      - lf-infra-github-pr-trigger:
-          trigger-phrase: '^remerge$'
-          only-trigger-phrase: true
-          status-context: 'JJB Merge'
-          permit-all: false
-          github-hooks: true
-          github-org: '{github-org}'
-          github_pr_whitelist: '{obj:github_pr_whitelist}'
-          github_pr_admin_list: '{obj:github_pr_admin_list}'
-
 - job-template:
     name: '{project-name}-jjb-verify'
     id: github-jjb-verify
     concurrent: true
-    <<: *lf_jjb_verify_merge
+    <<: *lf_jjb_common
     # yamllint disable-line rule:key-duplicates
     <<: *lf_jjb_verify_builders
 
           github_pr_admin_list:
             - ''
 
+################
+# Packer Merge #
+################
+
+- lf_packer_merge_builders: &lf_packer_merge_builders
+    name: lf-packer-merge-builders
+
+    # 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.
+
+    builders:
+      - lf-infra-packer-validate:
+          packer-cloud-settings: '{packer-cloud-settings}'
+          packer-version: '{packer-version}'
+      - lf-infra-packer-build:
+          packer-cloud-settings: '{packer-cloud-settings}'
+          packer-version: '{packer-version}'
+          platform: '{platforms}'
+          template: '{templates}'
+
 - job-template:
     name: '{project-name}-packer-merge-{platforms}-{templates}'
     id: gerrit-packer-merge
     concurrent: true
-    <<: *lf_jjb_verify_merge
+    <<: *lf_jjb_common
     # yamllint disable-line rule:key-duplicates
     <<: *lf_packer_common
     # yamllint disable-line rule:key-duplicates
                   branch-pattern: '**/{branch}'
               <<: *lf_packer_file_paths
 
+- 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 #
+    #####################
+
+    properties:
+      - github:
+          url: '{git-url}/{github-org}/{project}'
+
+    scm:
+      - lf-infra-github-scm:
+          url: '{git-clone-url}{github-org}/{project}'
+          refspec: ''
+          branch: '{branch}'
+          submodule-recursive: '{submodule-recursive}'
+          choosing-strategy: default
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    triggers:
+      - timed: '00 10 1 * *'
+      - github
+      - pollscm:
+          cron: ''
+      - lf-infra-github-pr-trigger:
+          trigger-phrase: '^remerge$'
+          only-trigger-phrase: true
+          status-context: 'Packer {platforms}-${templates} Merge'
+          permit-all: false
+          github-hooks: true
+          github-org: '{github-org}'
+          github_pr_whitelist: '{obj:github_pr_whitelist}'
+          github_pr_admin_list: '{obj:github_pr_admin_list}'
+
+#################
+# 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.
+
+    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_verify_merge
+    <<: *lf_jjb_common
     # yamllint disable-line rule:key-duplicates
     <<: *lf_packer_common
     # yamllint disable-line rule:key-duplicates
                   branch-pattern: '**/{branch}'
               <<: *lf_packer_file_paths
 
-
-- job-template:
-    name: '{project-name}-packer-merge-{platforms}-{templates}'
-    id: github-packer-merge
-    concurrent: true
-    <<: *lf_jjb_verify_merge
-    # yamllint disable-line rule:key-duplicates
-    <<: *lf_packer_common
-    # yamllint disable-line rule:key-duplicates
-    <<: *lf_packer_merge_builders
-
-    #####################
-    # Job Configuration #
-    #####################
-
-    properties:
-      - github:
-          url: '{git-url}/{github-org}/{project}'
-
-    scm:
-      - lf-infra-github-scm:
-          url: '{git-clone-url}{github-org}/{project}'
-          refspec: ''
-          branch: '{branch}'
-          submodule-recursive: '{submodule-recursive}'
-          choosing-strategy: default
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-
-    triggers:
-      - timed: '00 10 1 * *'
-      - github
-      - pollscm:
-          cron: ''
-      - lf-infra-github-pr-trigger:
-          trigger-phrase: '^remerge$'
-          only-trigger-phrase: true
-          status-context: 'Packer {platforms}-${templates} Merge'
-          permit-all: false
-          github-hooks: true
-          github-org: '{github-org}'
-          github_pr_whitelist: '{obj:github_pr_whitelist}'
-          github_pr_admin_list: '{obj:github_pr_admin_list}'
-
 - job-template:
     name: '{project-name}-packer-verify'
     id: github-packer-verify
     concurrent: true
-    <<: *lf_jjb_verify_merge
+    <<: *lf_jjb_common
     # yamllint disable-line rule:key-duplicates
     <<: *lf_packer_common
     # yamllint disable-line rule:key-duplicates
index 3f6de2e..2aa0beb 100644 (file)
       - github-maven-release
 
 ####################
-# Anchors & Macros #
+# COMMON FUNCTIONS #
 ####################
 
+- lf_maven_common: &lf_maven_common
+    name: lf-maven-common
+
+    project-type: freestyle
+    node: '{build-node}'
+    jdk: '{java-version}'
+
+    properties:
+      - lf-infra-properties:
+          build-days-to-keep: '{build-days-to-keep}'
+
+    parameters:
+      - lf-infra-parameters:
+          project: '{project}'
+          branch: '{branch}'
+          stream: '{stream}'
+      - lf-infra-maven-parameters:
+          mvn-opts: '{mvn-opts}'
+          mvn-params: '{mvn-params}'
+          mvn-version: '{mvn-version}'
+          # Staging repos do not make sense for CLM jobs so set it blank.
+          staging-profile-id: '{staging-profile-id}'
+
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: '{build-timeout}'
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    publishers:
+      # TODO: Make email notification work.
+      # - lf-infra-email-notify:
+      #     email-recipients: '{email-recipients}'
+      #     email-prefix: '[releng]'
+      - lf-infra-publish
+
+#############
+# Maven CLM #
+#############
+
 - lf_maven_clm: &lf_maven_clm
     name: lf-maven-clm
 
     #     mvn-global-settings: The name of the Maven global settings to use for
     #                          Maven configuration. (default: global-settings)
 
-    project-type: freestyle
-    node: '{build-node}'
-    jdk: '{java-version}'
-
     ######################
     # Default parameters #
     ######################
 
     branch: master
+    build-days-to-keep: 30  # 30 days for troubleshooting purposes
     build-timeout: 15
     git-url: '$GIT_URL/$PROJECT'
     java-version: openjdk8
     stream: master
     submodule-recursive: true
 
+    # Staging repos do not make sense for CLM jobs so set it blank.
+    staging-profile-id: ''
+
     #####################
     # Job Configuration #
     #####################
 
-    properties:
-      - lf-infra-properties:
-          # Keep around for 30 days for troubleshooting purposes.
-          build-days-to-keep: 30
-
-    parameters:
-      - lf-infra-parameters:
-          project: '{project}'
-          branch: '{branch}'
-          stream: '{stream}'
-      - lf-infra-maven-parameters:
-          mvn-opts: '{mvn-opts}'
-          mvn-params: '{mvn-params}'
-          mvn-version: '{mvn-version}'
-          # Staging repos do not make sense for CLM jobs so set it blank.
-          staging-profile-id: ''
-
-    wrappers:
-      - lf-infra-wrappers:
-          build-timeout: '{build-timeout}'
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-
     triggers:
       # Build weekly on Saturdays
       - timed: 'H H * * 6'
       - sonatype-clm:
           application-name: '{project-name}'
 
-    publishers:
-      - lf-infra-publish
+- job-template:
+    name: '{project-name}-maven-clm-{stream}'
+    id: gerrit-maven-clm
+    <<: *lf_maven_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_maven_clm
+
+    scm:
+      - lf-infra-gerrit-scm:
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          git-url: '{git-url}'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
+          submodule-recursive: '{submodule-recursive}'
+          choosing-strategy: default
+
+- job-template:
+    name: '{project-name}-maven-clm-{stream}'
+    id: github-maven-clm
+    <<: *lf_maven_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_maven_clm
+
+    properties:
+      - github:
+          url: '{git-url}/{github-org}/{project}'
+
+    scm:
+      - lf-infra-github-scm:
+          url: '{git-clone-url}{github-org}/{project}'
+          refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
+          branch: '{branch}'
+          submodule-recursive: '{submodule-recursive}'
+          choosing-strategy: default
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+#################
+# Maven Release #
+#################
 
 - lf_maven_release: &lf_maven_release
     name: lf-maven-release
     #     mvn-global-settings: The name of the Maven global settings to use for
     #                          Maven configuration. (default: global-settings)
 
-    project-type: freestyle
-    node: '{build-node}'
-    jdk: '{java-version}'
-
     ######################
     # Default parameters #
     ######################
 
     branch: master
+    build-days-to-keep: 30  # 30 days in case a release takes long to get approved.
     build-timeout: 30
     git-url: '$GIT_URL/$PROJECT'
     java-version: openjdk8
     # Job Configuration #
     #####################
 
-    properties:
-      - lf-infra-properties:
-          # Keep around for 30 days in case a release takes long to get approved.
-          build-days-to-keep: 30
-
-    parameters:
-      - lf-infra-parameters:
-          project: '{project}'
-          branch: '{branch}'
-          stream: '{stream}'
-      - lf-infra-maven-parameters:
-          mvn-opts: '{mvn-opts}'
-          mvn-params: '{mvn-params}'
-          mvn-version: '{mvn-version}'
-          staging-profile-id: '{staging-profile-id}'
-
-    wrappers:
-      - lf-infra-wrappers:
-          build-timeout: '{build-timeout}'
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-
     builders:
       - lf-jacoco-nojava-workaround
       - lf-maven-install:
           - ../shell/maven-stage.sh
       - lf-provide-maven-settings-cleanup
 
-    publishers:
-      # TODO: Make email notification work.
-      # - lf-infra-email-notify:
-      #     email-recipients: '{email-recipients}'
-      #     email-prefix: '[releng]'
-      - lf-infra-publish
-
-
-#################
-# Job Templates #
-#################
-
-- job-template:
-    name: '{project-name}-maven-clm-{stream}'
-    id: gerrit-maven-clm
-    <<: *lf_maven_clm
-
-    scm:
-      - lf-infra-gerrit-scm:
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-          git-url: '{git-url}'
-          refspec: '$GERRIT_REFSPEC'
-          branch: '$GERRIT_BRANCH'
-          submodule-recursive: '{submodule-recursive}'
-          choosing-strategy: default
-
-- job-template:
-    name: '{project-name}-maven-clm-{stream}'
-    id: github-maven-clm
-    <<: *lf_maven_clm
-
-    properties:
-      - github:
-          url: '{git-url}/{github-org}/{project}'
-
-    scm:
-      - lf-infra-github-scm:
-          url: '{git-clone-url}{github-org}/{project}'
-          refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
-          branch: '{branch}'
-          submodule-recursive: '{submodule-recursive}'
-          choosing-strategy: default
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-
 - job-template:
     name: '{project-name}-maven-release-{stream}'
     id: gerrit-maven-release
+    <<: *lf_maven_common
+    # yamllint disable-line rule:key-duplicates
     <<: *lf_maven_release
 
     scm:
 - job-template:
     name: '{project-name}-maven-release-{stream}'
     id: github-maven-release
+    <<: *lf_maven_common
+    # yamllint disable-line rule:key-duplicates
     <<: *lf_maven_release
 
     properties:
index 7f7fb50..42e0967 100644 (file)
@@ -17,9 +17,9 @@
     jobs:
       - github-tox-verify
 
-####################
-# Anchors & Macros #
-####################
+##############
+# Tox Verify #
+##############
 
 - lf_tox_verify: &lf_tox_verify
     name: lf-tox-verify
     publishers:
       - lf-infra-publish
 
-#################
-# Job Templates #
-#################
-
 - job-template:
     # Python projects typically use tox to run testing.
     name: '{project-name}-tox-verify-{stream}'