Merge "Add sonar-prescan jobs"
[releng/global-jjb.git] / jjb / lf-python-jobs.yaml
index 0c40326..451eb63 100644 (file)
@@ -7,7 +7,7 @@
     name: lf-infra-tox-install
     builders:
       - inject:
-          properties-content: "PYTHON_VERSION={python-version}"
+          properties-content: "PYTHON={python-version}"
       - shell: !include-raw-escape: ../shell/tox-install.sh
 
 - builder:
@@ -77,6 +77,7 @@
     java-version: openjdk8
     nexus-iq-cli-version: 1.44.0-01
     nexus-iq-namespace: "" # Recommend a trailing dash when set. Example: odl-
+    pre-build-script: "# pre-build script goes here"
     stream: master
     submodule-recursive: true
     submodule-timeout: 10
     builders:
       - lf-update-java-alternatives:
           java-version: "{java-version}"
+      - shell: "{pre-build-script}"
       - lf-infra-clm-python:
           clm-project-name: "{nexus-iq-namespace}{project-name}"
 
             - "{branch}"
           included-regions: "{obj:github_included_regions}"
 
-########################
+#########################
 # Python Sonar with Tox #
-########################
+#########################
 
 - lf_tox_sonar: &lf_tox_sonar
     name: lf-tox_sonar
     git-url: "$GIT_URL/$PROJECT"
     github-url: "https://github.com"
     java-version: openjdk8
-    python-version: python2
     mvn-global-settings: global-settings
+    mvn-goals: validate
     mvn-settings: "{mvn-settings}"
     mvn-version: mvn35
+    pre-build-script: "# pre-build script goes here"
+    python-version: python2
     sonar-mvn-goal: "sonar:sonar"
     stream: master
     submodule-recursive: true
       - lf-infra-pre-build
       - lf-infra-tox-install:
           python-version: "{python-version}"
+      - shell: "{pre-build-script}"
       - shell: !include-raw-escape: ../shell/tox-run.sh
       - lf-provide-maven-settings:
           global-settings-file: "{mvn-global-settings}"
           settings-file: "{mvn-settings}"
-      - lf-infra-tox-sonar:
+      - lf-infra-maven-sonar:
           java-version: "{java-version}"
+          mvn-goals: "{mvn-goals}"
           mvn-settings: "{mvn-settings}"
           mvn-version: "{mvn-version}"
 
     publishers:
       - lf-infra-publish
 
-- builder:
-    name: lf-infra-tox-sonar
-    # Run a Sonar build with Maven
-    builders:
-      - lf-maven-install:
-          mvn-version: "{mvn-version}"
-      - lf-update-java-alternatives:
-          java-version: "{java-version}"
-      - inject:
-          # TODO: Switch this to the sonar wrapper when JJB 2.0 is available
-          properties-content: SONAR_HOST_URL=$SONAR_URL
-      - shell: !include-raw-escape:
-          - ../shell/common-variables.sh
-          - ../shell/maven-sonar.sh
-      - lf-provide-maven-settings-cleanup
-
 - job-template:
     name: "{project-name}-tox-sonar"
     id: gerrit-tox-sonar
           included-regions: "{obj:github_included_regions}"
 
 ##############
-# Tox Verify #
+# Tox Common #
 ##############
 
-- lf_tox_verify: &lf_tox_verify
-    name: lf-tox-verify
+- lf_tox_common: &lf_tox_common
+    name: lf-tox-common
 
     ######################
     # Default parameters #
     git-url: "$GIT_URL/$GERRIT_PROJECT"
     github-url: "https://github.com"
     parallel: true
+    pre-build-script: "# pre-build script goes here"
     python-version: python2
     stream: master
     submodule-recursive: true
       - lf-infra-pre-build
       - lf-infra-tox-install:
           python-version: "{python-version}"
+      - shell: "{pre-build-script}"
       - shell: !include-raw-escape: ../shell/tox-run.sh
 
     publishers:
     # Python projects typically use tox to run testing.
     name: "{project-name}-tox-verify-{stream}"
     id: gerrit-tox-verify
-    <<: *lf_tox_verify
+    <<: *lf_tox_common
 
     ######################
     # Default parameters #
     # Python projects typically use tox to run testing.
     name: "{project-name}-tox-verify-{stream}"
     id: github-tox-verify
-    <<: *lf_tox_verify
+    <<: *lf_tox_common
 
     properties:
       - lf-infra-properties:
           white-list-target-branches:
             - "{branch}"
           included-regions: "{obj:github_included_regions}"
+
+- job-template:
+    # Run tox after merge of gerrit change set
+    name: "{project-name}-tox-merge-{stream}"
+    id: gerrit-tox-merge
+    <<: *lf_tox_common
+
+    ######################
+    # Default parameters #
+    ######################
+
+    gerrit_merge_triggers:
+      - change-merged-event
+      - comment-added-contains-event:
+          comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$'
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    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}"
+          submodule-timeout: "{submodule-timeout}"
+          submodule-disable: "{submodule-disable}"
+          choosing-strategy: gerrit
+
+    triggers:
+      - gerrit:
+          server-name: "{gerrit-server-name}"
+          trigger-on: "{obj:gerrit_merge_triggers}"
+          projects:
+            - project-compare-type: ANT
+              project-pattern: "{project}"
+              branches:
+                - branch-compare-type: ANT
+                  branch-pattern: "**/{branch}"
+              file-paths: "{obj:gerrit_trigger_file_paths}"
+
+- job-template:
+    # Run tox after merge of github pull request
+    name: "{project-name}-tox-merge-{stream}"
+    id: github-tox-merge
+    <<: *lf_tox_common
+
+    properties:
+      - lf-infra-properties:
+          build-days-to-keep: "{build-days-to-keep}"
+      - github:
+          url: "{github-url}/{github-org}/{project}"
+
+    scm:
+      - lf-infra-github-scm:
+          url: "{git-clone-url}{github-org}/{project}"
+          refspec: ""
+          branch: "refs/heads/{branch}"
+          submodule-recursive: "{submodule-recursive}"
+          submodule-timeout: "{submodule-timeout}"
+          submodule-disable: "{submodule-disable}"
+          choosing-strategy: default
+          jenkins-ssh-credential: "{jenkins-ssh-credential}"
+
+    triggers:
+      - github-pull-request:
+          trigger-phrase: "^remerge$"
+          only-trigger-phrase: true
+          status-context: "Tox Merge"
+          permit-all: true
+          github-hooks: true
+          org-list:
+            - "{github-org}"
+          white-list: "{obj:github_pr_whitelist}"
+          admin-list: "{obj:github_pr_admin_list}"
+          white-list-target-branches:
+            - "{branch}"
+          included-regions: "{obj:github_included_regions}"