sonarcloud-project-key: KEY
sonarcloud-project-organization: ORGANIZATION
sonarcloud-api-token: TOKEN
+ scan-dev-branch: false
- project:
name: example-sonarcloud-with-prescan-script
sonarcloud-api-token: TOKEN
sonar-prescan-script: |
echo "Run script at start of job."
+ scan-dev-branch: false
(default: 10)
:submodule-disable: Disable submodule checkout operation.
(default: false)
+ :scan-dev-branch: Run the scan on a developer branch.
+ (default: false)
:gerrit_sonar_triggers: Override Gerrit Triggers.
submodule-recursive: true
submodule-timeout: 10
submodule-disable: false
+ scan-dev-branch: false
gerrit_sonar_triggers:
- comment-added-contains-event:
sonarcloud-project-organization: "{sonarcloud-project-organization}"
sonarcloud-api-token: "{sonarcloud-api-token}"
sonarcloud-java-version: "{sonarcloud-java-version}"
+ scan-dev-branch: "{scan-dev-branch}"
# With SonarQube
- conditional-step:
condition-kind: not
sonarcloud-project-organization: "{sonarcloud-project-organization}"
sonarcloud-api-token: "{sonarcloud-api-token}"
sonarcloud-java-version: "{sonarcloud-java-version}"
+ scan-dev-branch: "{scan-dev-branch}"
# With SonarQube
- conditional-step:
condition-kind: not
MAVEN_GOALS={mvn-goals}
API_TOKEN={sonarcloud-api-token}
SONARCLOUD_JAVA_VERSION={sonarcloud-java-version}
+ SCAN_DEV_BRANCH={scan-dev-branch}
- lf-provide-maven-settings:
global-settings-file: global-settings
settings-file: "{mvn-settings}"
submodule-disable: false
tox-dir: "."
tox-envs: ""
+ scan-dev-branch: false
gerrit_trigger_file_paths:
- compare-type: REG_EXP
sonarcloud-project-organization: "{sonarcloud-project-organization}"
sonarcloud-api-token: "{sonarcloud-api-token}"
sonarcloud-java-version: "{sonarcloud-java-version}"
+ scan-dev-branch: "{scan-dev-branch}"
# With SonarQube
- conditional-step:
condition-kind: not
--- /dev/null
+---
+features:
+ - |
+ Add support in lf-maven-sonar scan jobs to process short lived dev branches.
params+=("-Dsonar.projectKey=$PROJECT_KEY")
params+=("-Dsonar.organization=$PROJECT_ORGANIZATION")
params+=("-Dsonar.login=$API_TOKEN")
+ if $SCAN_DEV_BRANCH; then
+ echo "Will scan short lived branch ..."
+ # shellcheck disable=SC2236
+ if [ ! -z ${GERRIT_CHANGE_NUMBER+x} ]; then
+ GERRIT_SHORT_LIVED_BRANCH=${GERRIT_CHANGE_NUMBER}-${GERRIT_PATCHSET_NUMBER}
+ params+=("-Dsonar.analysis.gerritProjectName=$PROJECT")
+ params+=("-Dsonar.branch.target=$GERRIT_BRANCH")
+ params+=("-Dsonar.branch.name=$GERRIT_SHORT_LIVED_BRANCH")
+ fi
+ fi
fi
if [ "$SET_JDK_VERSION" != "$SONARCLOUD_JAVA_VERSION" ]; then