From: Anil Belur Date: Wed, 16 Oct 2019 13:49:44 +0000 (+0000) Subject: Merge "Support sonarcloud in python projects" X-Git-Tag: v0.46.0~7 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;ds=sidebyside;h=8f45c24bd2d164ef934d68982662e045fcb0dcb2;hp=-c;p=releng%2Fglobal-jjb.git Merge "Support sonarcloud in python projects" --- 8f45c24bd2d164ef934d68982662e045fcb0dcb2 diff --combined docs/jjb/lf-python-jobs.rst index b23ed785,0ef27d9b..8f4f6bde --- a/docs/jjb/lf-python-jobs.rst +++ b/docs/jjb/lf-python-jobs.rst @@@ -128,7 -128,7 +128,7 @@@ Python Sonar with To Sonar scans for Python based repos. This job invokes tox to run tests and gather coverage statistics from the test results, then invokes - Maven to publish the results to a Sonar server. + Maven to publish the results to either a Sonar server or SonarCloud. To get the Sonar coverage results, file tox.ini must exist and contain coverage commands to run. @@@ -137,8 -137,8 +137,8 @@@ The coverage commands define the code t suites. Checking coverage does not guarantee that the tests execute properly, but it identifies code that is not executed by any test. - This job reuses the Sonar builder used in Java/Maven projects which - runs maven twice. The first invocation does nothing for Python + This job reuses the Sonar builders used for Java/Maven projects which + run maven twice. The first invocation does nothing for Python projects, so the job uses the goal 'validate' by default. The second invocation publishes results using the goal 'sonar:sonar' by default. @@@ -196,6 -196,12 +196,12 @@@ https://docs.sonarqube.org/display/PLUG (default: a string with a shell comment) :python-version: Python version to invoke pip install of tox-pyenv (default: python2) + :sonarcloud: Whether or not to use SonarCloud ``true|false``. + (default: false) + :sonarcloud-project-key: SonarCloud project key. (default: '') + :sonarcloud-project-organization: SonarCloud project organization. + (default: '') + :sonarcloud-api-token: SonarCloud API Token. (default: '') :sonar-mvn-goal: The Maven goal to run the Sonar plugin. (default: sonar:sonar) :stream: Keyword used to represent a release code-name. Often the same as the branch. (default: master) @@@ -205,6 -211,11 +211,11 @@@ (default: 10) :submodule-disable: Disable submodule checkout operation. (default: false) + :tox-dir: Directory containing the project's tox.ini relative to + the workspace. The default uses tox.ini at the project root. + (default: '.') + :tox-envs: Tox environments to run. If blank run everything described + in tox.ini. (default: '') :gerrit_sonar_triggers: Override Gerrit Triggers. :gerrit_trigger_file_paths: Override file paths used to filter which file modifications trigger a build. Refer to JJB documentation for "file-path" details. @@@ -438,7 -449,7 +449,7 @@@ PyPI section - gerrit-pypi-merge - github-pypi-merge -:Comment Trigger: pypi-remerge +:Comment Trigger: remerge :Required Parameters: @@@ -552,8 -563,6 +563,8 @@@ An example of a pypi release file appea - gerrit-pypi-release-verify - github-pypi-release-verify +:Comment Trigger: recheck + :Required Parameters: :build-node: The node to run build on, which must be Centos. @@@ -635,8 -644,6 +646,8 @@@ The special parameters are as follows: - gerrit-pypi-release-merge - github-pypi-release-merge +:Comment Trigger: remerge + :Required Parameters: :build-node: The node to run build on, which must be Centos. diff --combined jjb/lf-python-jobs.yaml index 8a96709d,df82d8fd..b334c78b --- a/jjb/lf-python-jobs.yaml +++ b/jjb/lf-python-jobs.yaml @@@ -267,10 -267,16 +267,16 @@@ 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 @@@ -291,6 -297,9 +297,9 @@@ 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}" @@@ -320,11 -329,33 +329,33 @@@ - 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 @@@ -673,9 -704,9 +704,9 @@@ pre-build-script: "# pre-build script goes here" python-version: python3 stream: master + submodule-disable: false submodule-recursive: true submodule-timeout: 10 - submodule-disable: false tox-dir: "." tox-envs: "" @@@ -769,6 -800,15 +800,6 @@@ <<: *lf_pypi_common <<: *lf_pypi_verify_builders - gerrit_verify_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*$' - scm: - lf-infra-gerrit-scm: jenkins-ssh-credential: "{jenkins-ssh-credential}" @@@ -783,14 -823,7 +814,14 @@@ triggers: - gerrit: server-name: "{gerrit-server-name}" - trigger-on: "{obj:gerrit_verify_triggers}" + trigger-on: + - 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*$' projects: - project-compare-type: ANT project-pattern: "{project}" @@@ -844,6 -877,11 +875,6 @@@ cron: "" pypi-repo: pypi-test - gerrit_merge_triggers: - - change-merged-event - - comment-added-contains-event: - comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$' - scm: - lf-infra-gerrit-scm: jenkins-ssh-credential: "{jenkins-ssh-credential}" @@@ -859,10 -897,7 +890,10 @@@ - timed: "{obj:cron}" - gerrit: server-name: "{gerrit-server-name}" - trigger-on: "{obj:gerrit_merge_triggers}" + trigger-on: + - change-merged-event + - comment-added-contains-event: + comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$' projects: - project-compare-type: ANT project-pattern: "{project}" @@@ -965,6 -1000,15 +996,6 @@@ <<: *lf_pypi_release_common <<: *lf_pypi_release_verify_builders - gerrit_verify_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*$' - scm: - lf-infra-gerrit-scm: jenkins-ssh-credential: "{jenkins-ssh-credential}" @@@ -979,14 -1023,7 +1010,14 @@@ triggers: - gerrit: server-name: "{gerrit-server-name}" - trigger-on: "{obj:gerrit_verify_triggers}" + trigger-on: + - 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*$' projects: - project-compare-type: "ANT" project-pattern: "{project}" @@@ -1039,6 -1076,9 +1070,6 @@@ <<: *lf_pypi_release_common <<: *lf_pypi_release_merge_builders - gerrit_release_triggers: - - change-merged-event - scm: - lf-infra-gerrit-scm: jenkins-ssh-credential: "{jenkins-ssh-credential}" @@@ -1053,10 -1093,7 +1084,10 @@@ triggers: - gerrit: server-name: "{gerrit-server-name}" - trigger-on: "{obj:gerrit_release_triggers}" + trigger-on: + - change-merged-event + - comment-added-contains-event: + comment-contains-value: '^Patch Set\s+\d+:\s+remerge\s*$' projects: - project-compare-type: "ANT" project-pattern: "{project}"