Update Jenkins Job Builder to version 2.9.1
[infra/cicd.git] / jjb / global / jjb-macros.yaml
index cfe19edf2d938fec5c727acb1f0c98ea8bef85af..c80cd45a347c3e4f31aa553150b79bd713ee4c22 100644 (file)
@@ -1,7 +1,7 @@
 ---
 # these parameters are used for infra related variables
 - parameter:
-    name: infra-parameter
+    name: infra-parameters
     parameters:
       - string:
           name: JJB_GIT_REPO
@@ -9,17 +9,21 @@
           description: OpenStack JJB repo
       - string:
           name: JJB_VERSION
-          default: 2.2.1
+          default: 2.9.1
           description: OpenStack JJB version to install - matches to LFN JJB version
 
 # these parameters are used for setting the Gerrit Project on Nordix
 - parameter:
-    name: project-parameter
+    name: project-parameters
     parameters:
       - string:
           name: PROJECT
           default: '{project}'
           description: JJB configured PROJECT parameter to identify a Nordix Gerrit project
+      - string:
+          name: BRANCH
+          default: '{branch}'
+          description: "JJB configured BRANCH parameter (e.g. master, nordix-dev)"
 
 # these parameters are used for streaming changes from various Gerrit Systems
 - parameter:
           description: Non-interactive user to stream Gerrit Events on Nordix Gerrit
       - string:
           name: GIT_BASE_HTTPS
-          default: https://gerrit.nordix.org/
+          default: https://gerrit.nordix.org
           description: HTTPS URL of Project Repo on Nordix Gerrit to clone repo
       - string:
           name: GIT_BASE_SSH
-          default: ssh://$GERRIT_USER@gerrit.nordix.org:29418/
+          default: ssh://$GERRIT_USER@gerrit.nordix.org:29418
           description: HTTPS URL of Project Repo on Nordix Gerrit to clone repo
 
 - parameter:
           description: Non-interactive user to stream Gerrit Events on ONAP Gerrit
       - string:
           name: GIT_BASE_HTTPS
-          default: https://gerrit.onap.org/r/p/
+          default: https://gerrit.onap.org/r/p
           description: HTTPS URL to Project Repo on ONAP Gerrit to clone repo
       - string:
           name: GIT_BASE_SSH
-          default: ssh://$GERRIT_USER@gerrit.onap.org:29418/
+          default: ssh://$GERRIT_USER@gerrit.onap.org:29418
           description: SSH URL to Project Repo on ONAP Gerrit to clone repo
 
 # defaults for job build history
 - scm:
     name: git-scm
     scm:
-      - git: &git-scm-defaults
-          url: '$GIT_BASE_HTTPS'
+      - git:
+          url: '$GIT_BASE_SSH/$PROJECT'
+          credentials-id: '{ssh-credentials-id}'
           branches:
-            - 'origin/$BRANCH'
+            - 'refs/heads/{branch}'
+          refspec: '{refspec}'
           timeout: 15
           per-build-tag: false
           skip-tag: true
           ignore-notify: false
           wipe-workspace: true
           prune: false
+          choosing-strategy: 'default'
 
 - scm:
     name: git-scm-gerrit
     scm:
       - git:
+          url: '$GIT_BASE_SSH/$PROJECT'
+          credentials-id: '{ssh-credentials-id}'
+          branches:
+            - 'refs/heads/{branch}'
+          refspec: '{refspec}'
+          timeout: 15
+          per-build-tag: false
+          skip-tag: true
+          shallow-clone: false
+          use-author: false
+          ignore-notify: false
+          wipe-workspace: true
+          prune: false
           choosing-strategy: 'gerrit'
-          refspec: '$GERRIT_REFSPEC'
-          <<: *git-scm-defaults
 
-# triggers for Nordix and upstream Gerrits
+# triggers for Nordix Gerrit
 - trigger:
     name: nordix-gerrit-trigger-patchset-created
     triggers:
             - comment-added-contains-event:
                 comment-contains-value: 'reverify'
           projects:
-            - project-compare-type: 'ANT'
+            - project-compare-type: 'REG_EXP'
               project-pattern: '{project}'
               branches:
                 - branch-compare-type: 'ANT'
               file-paths:
                 - compare-type: 'ANT'
                   pattern: '{files}'
+
+- trigger:
+    name: nordix-gerrit-push-upstream
+    triggers:
+      - gerrit:
+          server-name: 'Nordix Gerrit'
+          trigger-on:
+            - comment-added-contains-event:
+                comment-contains-value: 'push-upstream'
+          projects:
+            - project-compare-type: 'ANT'
+              project-pattern: '{project}'
+              branches:
+                - branch-compare-type: 'ANT'
+                  branch-pattern: '**/{branch}'
+              file-paths:
+                - compare-type: 'ANT'
+                  pattern: '{files}'
+
+# triggers for ONAP Gerrit
+- trigger:
+    name: onap-gerrit-trigger-change-merged
+    triggers:
+      - gerrit:
+          server-name: 'ONAP Gerrit'
+          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}'
+              file-paths:
+                - compare-type: 'ANT'
+                  pattern: '{files}'
+          silent: true
+          silent-start: true
+
+# wrappers to use for jobs
+- wrapper:
+    name: nordixinfra-jjb-creds-wrapper
+    wrappers:
+      - credentials-binding:
+          - username-password-separated:
+              credential-id: nordixinfra-jjb-creds
+              username: JJB_USERNAME
+              password: JJB_USERTOKEN
+
+# timeout wrapper to use for jobs
+- wrapper:
+    name: build-timeout
+    wrappers:
+      - timeout:
+          timeout: '{timeout}'
+          timeout-var: 'BUILD_TIMEOUT'
+          fail: true
+
+# wrapper to fix jenkins build workspace permissions
+- wrapper:
+    name: fix-workspace-permissions
+    wrappers:
+      - pre-scm-buildstep:
+          failOnError: true
+          buildsteps:
+            - shell: |
+                #!/bin/bash
+                sudo chown -R $USER:$USER $WORKSPACE || exit 1
+
+- publisher:
+    name: notify-slack
+    publishers:
+      - slack:
+          room: '{slack-channel}'
+          notify-failure: True
+
+# property to discard old builds
+- property:
+    name: logrotate
+    properties:
+      - build-discarder:
+          days-to-keep: 30
+          num-to-keep: 100
+          artifact-days-to-keep: 30
+          artifact-num-to-keep: 100