Support sonarcloud in python projects
[releng/global-jjb.git] / jjb / lf-python-jobs.yaml
index e28bc22..df82d8f 100644 (file)
     pre-build-script: "# pre-build script goes here"
     python-version: python3
     sonar-mvn-goal: "sonar:sonar"
+    sonarcloud: false
+    sonarcloud-project-key: ""
+    sonarcloud-project-organization: ""
+    sonarcloud-api-token: ""
     stream: master
     submodule-recursive: true
     submodule-timeout: 10
     submodule-disable: false
+    tox-dir: "."
+    tox-envs: ""
 
     gerrit_trigger_file_paths:
       - compare-type: REG_EXP
           project: "{project}"
           branch: "{branch}"
           stream: "{stream}"
+      - lf-infra-tox-parameters:
+          tox-dir: "{tox-dir}"
+          tox-envs: "{tox-envs}"
       - string:
           name: ARCHIVE_ARTIFACTS
           default: "{archive-artifacts}"
       - lf-provide-maven-settings:
           global-settings-file: "{mvn-global-settings}"
           settings-file: "{mvn-settings}"
-      - lf-infra-maven-sonar:
-          java-version: "{java-version}"
-          mvn-goals: "{mvn-goals}"
-          mvn-settings: "{mvn-settings}"
-          mvn-version: "{mvn-version}"
+      # 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-api-token: "{sonarcloud-api-token}"
+      # 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}"
 
     publishers:
       - lf-infra-publish
     tox-dir: "."
     tox-envs: ""
 
+    disabled: "{disable-job}"
+
     gerrit_trigger_file_paths:
       - compare-type: ANT
         pattern: ".*"
           name: BUILD_BDIST_WHEEL
           default: "{dist-binary}"
           description: "Set to True to build a wheel"
+      - bool:
+          name: DRY_RUN
+          default: false
+          description: |
+            If DRY_RUN is enabled artifacts are not published.
 
 - lf_pypi_verify_builders: &lf_pypi_verify_builders
     name: lf-pypi-verify-builders
     <<: *lf_pypi_common
     <<: *lf_pypi_merge_builders
 
-    pypi-repo: staging
+    cron: ""
+    pypi-repo: pypi-test
 
     gerrit_merge_triggers:
       - change-merged-event
           choosing-strategy: gerrit
 
     triggers:
+      - timed: "{obj:cron}"
       - gerrit:
           server-name: "{gerrit-server-name}"
           trigger-on: "{obj:gerrit_merge_triggers}"
     <<: *lf_pypi_common
     <<: *lf_pypi_merge_builders
 
-    pypi-repo: staging
+    cron: ""
+    pypi-repo: pypi-test
 
     properties:
       - github:
           jenkins-ssh-credential: "{jenkins-ssh-credential}"
 
     triggers:
+      - timed: "{obj:cron}"
       - github-pull-request:
           trigger-phrase: "^remerge$"
           only-trigger-phrase: false
     pypi-repo: pypi
     use-release-file: true
 
-    gerrit_trigger_file_paths:
+    # define once and use twice; jobs MUST NOT override
+    gerrit_release_trigger_file_paths:
       - compare-type: REG_EXP
         pattern: '(releases\/.*\.yaml|\.releases\/.*\.yaml)'
 
-    # github_included_regions MUST match gerrit_trigger_file_paths
-    github_included_regions:
+    # github_release_included_regions MUST match gerrit_release_trigger_file_paths
+    github_release_included_regions:
       - 'releases\/.*\.yaml'
       - '.releases\/.*\.yaml'
 
             - project-compare-type: "ANT"
               project-pattern: "{project}"
               branches:
-                - branch-compare-type: "ANT"
-                  branch-pattern: "**"
-              file-paths: "{obj:gerrit_trigger_file_paths}"
+                - branch-compare-type: ANT
+                  branch-pattern: "**/{branch}"
+              file-paths: "{obj:gerrit_release_trigger_file_paths}"
 
 - job-template:
     name: "{project-name}-pypi-release-verify-{stream}"
           github-hooks: true
           white-list-target-branches:
             - "{branch}"
-          included-regions: "{obj:github_included_regions}"
+          included-regions: "{obj:github_release_included_regions}"
 
 - job-template:
     name: "{project-name}-pypi-release-merge-{stream}"
             - project-compare-type: "ANT"
               project-pattern: "{project}"
               branches:
-                - branch-compare-type: "ANT"
-                  branch-pattern: "**"
-              file-paths: "{obj:gerrit_trigger_file_paths}"
+                - branch-compare-type: ANT
+                  branch-pattern: "**/{branch}"
+              file-paths: "{obj:gerrit_release_trigger_file_paths}"
 
 - job-template:
     name: "{project-name}-pypi-release-merge-{stream}"
           github-hooks: true
           white-list-target-branches:
             - "{branch}"
-          included-regions: "{obj:github_included_regions}"
+          included-regions: "{obj:github_release_included_regions}"