+ submodule-timeout: 10
+ submodule-disable: false
+ scan-dev-branch: false
+
+ gerrit_sonar_triggers:
+ - comment-added-contains-event:
+ comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
+
+ #####################
+ # Job Configuration #
+ #####################
+
+ disabled: "{disable-job}"
+
+ 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}"
+ - string:
+ name: ARCHIVE_ARTIFACTS
+ default: "{archive-artifacts}"
+ description: Artifacts to archive to the logs server.
+ - string:
+ name: JAVA_OPTS
+ default: "{java-opts}"
+ description: |
+ Java options. Example: -Xmx1024m
+ - string:
+ name: SONAR_MAVEN_GOAL
+ default: "{sonar-mvn-goal}"
+ description: |
+ Maven goals to pass to the Sonar call. Typically sonar:sonar
+ however to use a specific version of the sonar-maven-plugin we
+ can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
+
+ wrappers:
+ - credentials-binding:
+ - text:
+ credential-id: "{sonarcloud-api-token-cred-id}"
+ variable: API_TOKEN
+
+ triggers:
+ - timed: "{obj:cron}"
+ - 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
+
+ publishers:
+ - lf-jacoco-report
+ - findbugs
+ - lf-infra-publish
+
+- _mvn_sonar_builders: &mvn_sonar_builders
+ name: mvn-sonar-builders
+ builders:
+ - lf-infra-pre-build
+ # With SonarCloud
+ - conditional-step:
+ condition-kind: boolean-expression
+ condition-expression: "{sonarcloud}"
+ steps:
+ - shell: echo 'Using SonarCloud'
+ - lf-infra-maven-sonarcloud:
+ java-version: "{java-version}"
+ mvn-goals: "{mvn-goals}"
+ mvn-settings: "{mvn-settings}"
+ mvn-version: "{mvn-version}"
+ sonarcloud-project-key: "{sonarcloud-project-key}"
+ sonarcloud-project-organization: "{sonarcloud-project-organization}"
+ sonarcloud-java-version: "{sonarcloud-java-version}"
+ sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
+ scan-dev-branch: "{scan-dev-branch}"
+ # With SonarQube
+ - conditional-step:
+ condition-kind: not
+ condition-operand:
+ condition-kind: boolean-expression
+ condition-expression: "{sonarcloud}"
+ steps:
+ - shell: echo 'Using SonarQube'
+ - lf-infra-maven-sonar:
+ java-version: "{java-version}"
+ mvn-goals: "{mvn-goals}"
+ mvn-settings: "{mvn-settings}"
+ mvn-version: "{mvn-version}"
+
+- _mvn_sonar_builders_prescan_script: &mvn_sonar_builders_prescan_script
+ name: mvn-sonar-builders-prescan-script
+ builders:
+ - shell: "{sonar-prescan-script}"
+ - lf-infra-pre-build
+ # With SonarCloud
+ - conditional-step:
+ condition-kind: boolean-expression
+ condition-expression: "{sonarcloud}"
+ steps:
+ - shell: echo 'Using SonarCloud'
+ - lf-infra-maven-sonarcloud:
+ java-version: "{java-version}"
+ mvn-goals: "{mvn-goals}"
+ mvn-settings: "{mvn-settings}"
+ mvn-version: "{mvn-version}"
+ sonarcloud-project-key: "{sonarcloud-project-key}"
+ sonarcloud-project-organization: "{sonarcloud-project-organization}"
+ sonarcloud-java-version: "{sonarcloud-java-version}"
+ sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
+ scan-dev-branch: "{scan-dev-branch}"
+ # With SonarQube
+ - conditional-step:
+ condition-kind: not
+ condition-operand:
+ condition-kind: boolean-expression
+ condition-expression: "{sonarcloud}"
+ steps:
+ - shell: echo 'Using SonarQube'
+ - lf-infra-maven-sonar:
+ java-version: "{java-version}"
+ mvn-goals: "{mvn-goals}"
+ mvn-settings: "{mvn-settings}"
+ mvn-version: "{mvn-version}"
+
+- builder:
+ name: lf-infra-maven-sbom-generator
+ # Run Maven goals and trigger SPDX SBOM Generator tool
+ builders:
+ - inject:
+ properties-content: |
+ SBOM_FLAGS={sbom-flags}
+ - shell: !include-raw-escape:
+ - ../shell/sbom-generator.sh
+
+- builder:
+ name: lf-infra-maven-sonar
+ # Run a Sonar build with Maven
+ builders:
+ - lf-maven-install:
+ mvn-version: "{mvn-version}"
+ - lf-update-java-alternatives:
+ java-version: "{java-version}"
+ - inject:
+ # Switch this to the sonar wrapper when JJB 2.0 is available
+ properties-content: |
+ SONAR_HOST_URL=$SONAR_URL
+ MAVEN_GOALS={mvn-goals}
+ - 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
+
+- builder:
+ name: lf-infra-maven-sonarcloud
+ # Run a Sonar build with Maven
+ builders:
+ - lf-maven-install:
+ mvn-version: "{mvn-version}"
+ - lf-update-java-alternatives:
+ java-version: "{java-version}"
+ - inject:
+ # Switch this to the sonar wrapper when JJB 2.0 is available
+ properties-content: |
+ SONAR_HOST_URL=https://sonarcloud.io
+ PROJECT_KEY={sonarcloud-project-key}
+ PROJECT_ORGANIZATION={sonarcloud-project-organization}
+ MAVEN_GOALS={mvn-goals}
+ SONARCLOUD_JAVA_VERSION={sonarcloud-java-version}
+ SCAN_DEV_BRANCH={scan-dev-branch}
+ SONARCLOUD_QUALITYGATE_WAIT={sonarcloud-qualitygate-wait}
+ - 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
+ <<: *mvn_sonar_builders
+
+ 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: default
+
+- job-template:
+ name: "{project-name}-sonar-verify"
+ id: gerrit-maven-sonar-verify
+ <<: *lf_maven_common
+ # yamllint disable-line rule:key-duplicates
+ <<: *lf_maven_sonar
+ <<: *mvn_sonar_builders
+
+ sonarcloud: true
+ scan-dev-branch: true
+ sonarcloud-qualitygate-wait: false
+
+ gerrit_sonar_triggers:
+ - patchset-created-event:
+ exclude-drafts: true
+ exclude-trivial-rebase: false
+ exclude-no-code-change: false
+ - draft-published-event
+ - comment-added-contains-event:
+ comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
+
+ gerrit_trigger_file_paths:
+ - compare-type: REG_EXP
+ pattern: ".*"
+
+ triggers:
+ - 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: "**/{branch}"
+ file-paths: "{obj:gerrit_trigger_file_paths}"
+
+ 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
+
+- job-template:
+ name: "{project-name}-sonar-prescan-script"
+ id: gerrit-maven-sonar-prescan-script
+ <<: *lf_maven_common
+ # yamllint disable-line rule:key-duplicates
+ <<: *lf_maven_sonar
+ <<: *mvn_sonar_builders_prescan_script
+
+ 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: default
+
+- job-template:
+ name: "{project-name}-sonar"
+ id: github-maven-sonar
+ <<: *lf_maven_common
+ # yamllint disable-line rule:key-duplicates
+ <<: *lf_maven_sonar
+
+ 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: "+refs/pull/*:refs/remotes/origin/pr/*"
+ branch: "$sha1"
+ submodule-recursive: "{submodule-recursive}"
+ submodule-timeout: "{submodule-timeout}"
+ submodule-disable: "{submodule-disable}"
+ choosing-strategy: default
+ jenkins-ssh-credential: "{jenkins-ssh-credential}"
+
+ triggers:
+ - timed: "{obj:cron}"
+ - github-pull-request:
+ trigger-phrase: "^run-sonar$"
+ only-trigger-phrase: true
+ status-context: "Maven Sonar"
+ permit-all: true
+ github-hooks: true
+ org-list:
+ - "{github-org}"
+ white-list: "{obj:github_pr_allowlist}"
+ admin-list: "{obj:github_pr_admin_list}"
+ white-list-target-branches:
+ - "{branch}"
+
+- job-template:
+ name: "{project-name}-sonar-prescan-script"
+ id: github-maven-sonar-prescan-script
+ <<: *lf_maven_common
+ # yamllint disable-line rule:key-duplicates
+ <<: *lf_maven_sonar
+ <<: *mvn_sonar_builders_prescan_script
+
+ 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: "+refs/pull/*:refs/remotes/origin/pr/*"
+ branch: "$sha1"
+ submodule-recursive: "{submodule-recursive}"
+ submodule-timeout: "{submodule-timeout}"
+ submodule-disable: "{submodule-disable}"
+ choosing-strategy: default
+ jenkins-ssh-credential: "{jenkins-ssh-credential}"
+
+ triggers:
+ - timed: "{obj:cron}"
+ - github-pull-request:
+ trigger-phrase: "^run-sonar$"
+ only-trigger-phrase: true
+ status-context: "Maven Sonar"
+ permit-all: true
+ github-hooks: true
+ org-list:
+ - "{github-org}"
+ white-list: "{obj:github_pr_allowlist}"
+ admin-list: "{obj:github_pr_admin_list}"
+ white-list-target-branches:
+ - "{branch}"
+
+################
+# Maven Verify #
+################
+
+- _lf_maven_verify: &lf_maven_verify
+ name: lf-maven-verify
+
+ ######################
+ # Default parameters #
+ ######################
+
+ branch: master
+ build-days-to-keep: 7
+ build-timeout: 60
+ disable-job: false
+ git-url: "$GIT_URL/$PROJECT"
+ github-url: "https://github.com"
+ java-version: openjdk11
+ mvn-global-settings: global-settings
+ mvn-goals: clean deploy
+ mvn-opts: ""
+ mvn-params: "-Dstream=$STREAM -Dmaven.source.skip=true"
+ mvn-version: mvn35
+ pre-build-script: "# pre-build script goes here"
+ post-build-script: "# post-build script goes here"
+ stream: master
+ submodule-recursive: true
+ submodule-timeout: 10
+ submodule-disable: false