Add generic packer templates
[releng/global-jjb.git] / jjb / lf-ci-jobs.yaml
index 8005bdc..4191a9c 100644 (file)
       - gerrit-jjb-merge
       - gerrit-jjb-verify
 
+- job-group:
+    name: '{project-name}-github-ci-jobs'
+
+    # This job group contains all the recommended jobs that should be deployed
+    # for any project ci that is using github.
+
+    jjb-version: 1.6.2
+
+    jobs:
+      - github-jjb-merge
+      - github-jjb-verify
+
+
+- job-group:
+    name: '{project-name}-packer-jobs'
+
+    # This job group contains all the recommended jobs that should be deployed
+    # for any project ci that is using packer.
+
+    packer-version: 1.0.2
+
+    jobs:
+      - gerrit-packer-merge
+      - gerrit-packer-verify
+
+
+- job-group:
+    name: '{project-name}-github-packer-jobs'
+
+    # This job group contains all the recommended jobs that should be deployed
+    # for any project ci that is using packer.
+
+    packer-version: 1.0.2
+
+    jobs:
+      - github-packer-merge
+      - github-packer-verify
+
+
 ####################
 # Anchors & Macros #
 ####################
       - compare-type: ANT
         pattern: '**/*.yaml'
 
+- lf_packer_file_paths: &lf_packer_file_paths
+    name: lf-packer-file-paths
+    file-paths:
+      # Common files for all projects
+      - compare-type: ANT
+        pattern: 'packer/vars/{platforms}.json'
+      - compare-type: ANT
+        pattern: 'packer/templates/{templates}.json'
+      - compare-type: ANT
+        pattern: 'packer/provision/{templates}.sh'
+      - compare-type: ANT
+        pattern: 'packer/provision/lib/**'
+
 - lf_jjb_merge_builders: &lf_jjb_merge_builders
     name: lf-jjb-merge-builders
     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
-      - gpg-verify-git-signature
+      - lf-infra-gpg-verify-git-signature
+
+- lf_packer: &lf_packer_common
+    name: lf-packer-common
+    # Adds wrappers and parameters sections common to packer jobs.
+    wrappers:
+      - lf-infra-wrappers:
+          build-timeout: 60
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    parameters:
+      - lf-infra-parameters:
+          project: '{project}'
+          stream: '{stream}'
+          branch: '{branch}'
+      - 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.
+    builders:
+      - lf-infra-packer-validate:
+          os-cloud-file-id: '{os-cloud-file-id}'
+          packer-version: '{packer-version}'
+      - lf-infra-packer-build:
+          platform: '{platforms}'
+          template: '{templates}'
+          os-cloud-file-id: '{os-cloud-file-id}'
+          packer-version: '{packer-version}'
+
+- lf_packer_verify_builders: &lf_packer_verify_builders
+    # Adds builders section common to verify packer jobs.
+    name: lf-packer-verify-builders
+    builders:
+      - lf-infra-packer-validate:
+          os-cloud-file-id: '{os-cloud-file-id}'
+          packer-version: '{packer-version}'
 
 - parameter:
     name: lf-infra-jjb-parameters
           default: '{jjb-version}'
           description: Jenkins Job Builder version to download and install.
 
+- parameter:
+    name: lf-infra-packer-parameters
+    parameters:
+      - string:
+          name: PACKER_VERSION
+          default: '{packer-version}'
+          description: Packer version to download and install.
+
+
 #################
 # Job Templates #
 #################
     # Default parameters #
     ######################
 
+    stream: master
     branch: master
     submodule-recursive: true
 
     parameters:
       - lf-infra-parameters:
           project: '{project}'
+          stream: '{stream}'
           branch: '{branch}'
       - lf-infra-jjb-parameters:
           jjb-version: '{jjb-version}'
     # yamllint disable-line rule:key-duplicates
     <<: *lf_jjb_merge_builders
 
+    ######################
+    # Default parameters #
+    ######################
+
+    git-url: '$GIT_URL/$GERRIT_PROJECT'
+
+    #####################
+    # Job Configuration #
+    #####################
+
     scm:
       - lf-infra-gerrit-scm:
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          git-url: '{git-url}'
           refspec: ''
           branch: '{branch}'
           submodule-recursive: '{submodule-recursive}'
           choosing-strategy: default
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
 
     triggers:
       - gerrit:
     # yamllint disable-line rule:key-duplicates
     <<: *lf_jjb_verify_builders
 
+    ######################
+    # Default parameters #
+    ######################
+
+    git-url: '$GIT_URL/$GERRIT_PROJECT'
+
+    #####################
+    # Job Configuration #
+    #####################
+
     scm:
       - lf-infra-gerrit-scm:
+          git-url: '{git-url}'
           refspec: '$GERRIT_REFSPEC'
           branch: '$GERRIT_BRANCH'
           submodule-recursive: '{submodule-recursive}'
                 - branch-compare-type: ANT
                   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
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_jjb_verify_builders
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    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}'
+
+    triggers:
+      - lf-infra-github-pr-trigger:
+          trigger-phrase: '^recheck$'
+          only-trigger-phrase: false
+          status-context: 'JJB Verify'
+          permit-all: true
+          github-hooks: true
+          github-org: ''
+          github_pr_whitelist:
+            - ''
+          github_pr_admin_list:
+            - ''
+
+- job-template:
+    name: '{project-name}-packer-merge-{platforms}-{templates}'
+    id: gerrit-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
+
+    ######################
+    # Default parameters #
+    ######################
+
+    git-url: '$GIT_URL/$GERRIT_PROJECT'
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    scm:
+      - lf-infra-gerrit-scm:
+          git-url: '{git-url}'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
+          submodule-recursive: '{submodule-recursive}'
+          choosing-strategy: gerrit
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    triggers:
+      - gerrit:
+          server-name: '{gerrit-server-name}'
+          trigger-on:
+            - change-merged-event
+            - comment-added-contains-event:
+                comment-contains-value: remerge$
+          projects:
+            - project-compare-type: ANT
+              project-pattern: '{project}'
+              branches:
+                - branch-compare-type: ANT
+                  branch-pattern: '**/{branch}'
+              <<: *lf_packer_file_paths
+
+- job-template:
+    name: '{project-name}-packer-verify'
+    id: gerrit-packer-verify
+    concurrent: true
+    <<: *lf_jjb_verify_merge
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_packer_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_packer_verify_builders
+
+    ######################
+    # Default parameters #
+    ######################
+
+    git-url: '$GIT_URL/$GERRIT_PROJECT'
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    scm:
+      - lf-infra-gerrit-scm:
+          git-url: '{git-url}'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
+          submodule-recursive: '{submodule-recursive}'
+          choosing-strategy: gerrit
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+
+    triggers:
+      - gerrit:
+          server-name: '{gerrit-server-name}'
+          trigger-on:
+            - patchset-created-event:
+                exclude-drafts: false
+                exclude-trivial-rebase: false
+                exclude-no-code-change: false
+            - draft-published-event
+            - comment-added-contains-event:
+                comment-contains-value: recheck$
+          projects:
+            - project-compare-type: ANT
+              project-pattern: '{project}'
+              branches:
+                - branch-compare-type: ANT
+                  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:
+      - 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}-packer-verify'
+    id: github-packer-verify
+    concurrent: true
+    <<: *lf_jjb_verify_merge
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_packer_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_packer_verify_builders
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    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}'
+
+    triggers:
+      - lf-infra-github-pr-trigger:
+          trigger-phrase: '^recheck$'
+          only-trigger-phrase: false
+          status-context: 'JJB Verify'
+          permit-all: true
+          github-hooks: true
+          github-org: ''
+          github_pr_whitelist:
+            - ''
+          github_pr_admin_list:
+            - ''