Merge "Feat: use credential for sonarcloud token"
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Thu, 1 Dec 2022 21:35:02 +0000 (21:35 +0000)
committerGerrit Code Review <gerrit@linuxfoundation.org>
Thu, 1 Dec 2022 21:35:02 +0000 (21:35 +0000)
1  2 
docs/jjb/lf-python-jobs.rst
jjb/lf-python-jobs.yaml

@@@ -112,8 -112,6 +112,8 @@@ does not support multi-branch
          share a Nexus IQ system to avoid project name collision. We recommend
          inserting a trailing - dash if using this parameter.
          For example 'odl-'. (default: '')
 +    :nexus-target-build: Target directory or file to be scanned by Nexus IQ CLI
 +        (default: "\*\*/\*")
      :pre-build-script: Shell script to run before tox. Useful for setting up
          dependencies. (default: a string with a shell comment)
      :python-version: Python version to invoke pip install of tox-pyenv
@@@ -195,7 -193,9 +195,9 @@@ https://docs.sonarcloud.io/advanced-set
      :sonarcloud-project-key: SonarCloud project key. (default: '')
      :sonarcloud-project-organization: SonarCloud project organization.
          (default: '')
-     :sonarcloud-api-token: SonarCloud API Token. (default: '')
+     :sonarcloud-api-token-cred-id: Jenkins credential ID which has the SonarCloud API Token.
+         This one SHOULDN'T be overwritten as per we are standarizing the credential ID for all
+         projects (default: 'sonarcloud-api-token')
      :sonar-scanner-home: Sonar scanner home directory.
          (default: $WORKSPACE/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux)
      :sonar-scanner-opts: Sonar scanner Java options. (default: '-server')
@@@ -308,7 -308,9 +310,9 @@@ https://docs.sonarqube.org/display/PLUG
      :sonarcloud-project-key: SonarCloud project key. (default: '')
      :sonarcloud-project-organization: SonarCloud project organization.
          (default: '')
-     :sonarcloud-api-token: SonarCloud API Token. (default: '')
+     :sonarcloud-api-token-cred-id: Jenkins credential ID which has the SonarCloud API Token.
+         This one SHOULDN'T be overwritten as per we are standarizing the credential ID for all
+         projects (default: 'sonarcloud-api-token')
      :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)
diff --combined jjb/lf-python-jobs.yaml
@@@ -86,7 -86,6 +86,7 @@@
      java-version: openjdk11 # Scanner is a jar
      nexus-iq-cli-version: 1.140.0-01
      nexus-iq-namespace: "" # Recommend a trailing dash when set. Example: odl-
 +    nexus-target-build: "**/*"
      pre-build-script: "# pre-build script goes here"
      python-version: python3
      requirements-file: requirements.txt
            name: NEXUS_IQ_CLI_VERSION
            default: "{nexus-iq-cli-version}"
            description: Nexus IQ CLI jar to download and run.
 +      - string:
 +          name: NEXUS_TARGET_BUILD
 +          default: "{nexus-target-build}"
 +          description: File or dir to scan by Nexus CLI.
  
      wrappers:
        - lf-infra-wrappers:
      sonarcloud: false
      sonarcloud-project-key: ""
      sonarcloud-project-organization: ""
-     sonarcloud-api-token: ""
+     sonarcloud-api-token-cred-id: sonarcloud-api-token
      sonarcloud-qualitygate-wait: false
      # SonarCloud scan using jdk8 will become deprecated by Oct, 2020
      # Projects not compatible with jdk11 can set java-version to something else
              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
      builders:
        - lf-infra-pre-build
        - lf-infra-tox-install:
                  sonarcloud-project-key: "{sonarcloud-project-key}"
                  # yamllint disable-line rule:line-length
                  sonarcloud-project-organization: "{sonarcloud-project-organization}"
-                 sonarcloud-api-token: "{sonarcloud-api-token}"
                  sonarcloud-java-version: "{sonarcloud-java-version}"
                  sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
                  scan-dev-branch: "{scan-dev-branch}"