Migrate sonar job
[releng/global-jjb.git] / jjb / lf-maven-jobs.yaml
index 1dd899e..73f567e 100644 (file)
             - ''
           github_pr_admin_list:
             - ''
+
+###############
+# Maven Sonar #
+###############
+
+- lf_maven_sonar: &lf_maven_sonar
+    name: lf-maven-sonar
+
+    # Sonar job which runs mvn clean install then publishes to Sonar.
+    #
+    # This job purposely only runs on the master branch as there are Additional
+    # configuration needed to support multiple branches and there's not much
+    # interest in that kind of support.
+    #
+    # 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:
+    #
+    #     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
+    #     :build-timeout: Timeout in seconds before aborting build. (default: 60)
+    #     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
+    #     :java-version: Version of Java to use for the build. (default: openjdk8)
+    #     :mvn-global-settings: The name of the Maven global settings to use for
+    #         Maven configuration. (default: global-settings)
+    #     :mvn-opts: Sets MAVEN_OPTS. (default: '')
+    #     :mvn-params: Additional mvn parameters to pass to the cli. (default: '')
+    #     :mvn-version: Version of maven to use. (default: mvn33)
+    #     :submodule-recursive: Whether to checkout submodules recursively.
+    #         (default: true)
+    #
+    #     :gerrit_sonar_triggers: Override Gerrit Triggers.
+
+    ######################
+    # Default parameters #
+    ######################
+
+    branch: master  # Sonar should always be run on master branch
+    build-days-to-keep: 7
+    build-timeout: 30
+    git-url: '$GIT_URL/$PROJECT'
+    java-version: openjdk8
+    mvn-global-settings: global-settings
+    mvn-opts: ''
+    mvn-params: ''
+    mvn-version: mvn33
+    stream: master
+    submodule-recursive: true
+
+    gerrit_sonar_triggers:
+      - comment-added-contains-event:
+          comment-contains-value: run-sonar$
+
+    # Staging repos do not make sense for CLM jobs so set it blank.
+    staging-profile-id: ''
+
+    #####################
+    # Job Configuration #
+    #####################
+
+    triggers:
+      - timed: 'H H * * 6'
+      - gerrit:
+          server-name: '{gerrit-server-name}'
+          trigger-on: '{obj:gerrit_sonar_triggers}'
+          projects:
+            - project-compare-type: 'ANT'
+              project-pattern: '{project}'
+              branches:
+                - branch-compare-type: 'ANT'
+                  branch-pattern: '**/master'
+          skip-vote:
+            successful: true
+            failed: true
+            unstable: true
+            notbuilt: true
+
+    builders:
+      - lf-infra-maven-sonar:
+          mvn-settings: '{mvn-settings}'
+          mvn-version: '{mvn-version}'
+
+    publishers:
+      - lf-jacoco-report
+      - findbugs
+      - lf-infra-publish
+
+- builder:
+    name: lf-infra-maven-sonar
+    # Run a Sonar build with Maven
+    builders:
+      - lf-maven-install:
+          mvn-version: '{mvn-version}'
+      - inject:
+          # Switch this to the sonar wrapper when JJB 2.0 is available
+          properties-content: |
+              SONAR_HOST_URL=$SONAR_URL
+              SONAR_MAVEN_GOAL=sonar:sonar
+      - lf-provide-maven-settings:
+          global-settings-file: global-settings
+          settings-file: '{mvn-settings}'
+      - shell: !include-raw-escape:
+          - ../shell/common-variables.sh
+          - ../shell/maven-sonar.sh
+      - lf-provide-maven-settings-cleanup
+
+- job-template:
+    name: '{project-name}-sonar'
+    id: gerrit-maven-sonar
+    <<: *lf_maven_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_maven_sonar
+
+    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}-sonar'
+    id: github-maven-sonar
+    <<: *lf_maven_common
+    # yamllint disable-line rule:key-duplicates
+    <<: *lf_maven_sonar
+
+    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: 'Maven Verify'
+          permit-all: true
+          github-hooks: true
+          github-org: ''
+          github_pr_whitelist:
+            - ''
+          github_pr_admin_list:
+            - ''