Skip to content

Commit 89efec0

Browse files
Added test.exclusions parameter and set default values
Signed-off-by: pierantoniomerlino <pierantonio.merlino@eurotech.com>
1 parent 70d4a56 commit 89efec0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

vars/continuousIntegrationPipeline.groovy

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def call(Map pipelineParams = [:]) {
3131
def defaultParameters = [
3232
toolchain: [ jdk: "temurin-jdk17-latest", maven: "apache-maven-3.9.6" ],
3333
buildType: "install",
34-
sonar: [ enable: false, projectKey: null, tokenId: null, exclusions: null ],
34+
sonar: [ enable: false, projectKey: null, tokenId: null, exclusions: "*.xml", testExclusions: "**/*.java,*.xml" ],
3535
pushArtifacts: true
3636
]
3737
pipelineParams = defaultParameters << pipelineParams
@@ -71,6 +71,8 @@ def call(Map pipelineParams = [:]) {
7171
// Validate that exclusions don't contain potentially dangerous characters
7272
assert pipelineParams.sonar.exclusions instanceof String
7373
assert !pipelineParams.sonar.exclusions.matches(/.*[;&|`$(){}\[\]\"].*/) : "sonar.exclusions contains potentially dangerous characters"
74+
assert pipelineParams.sonar.testExclusions instanceof String
75+
assert !pipelineParams.sonar.testExclusions.matches(/.*[;&|`$(){}\[\]\"].*/) : "sonar.test.exclusions contains potentially dangerous characters"
7476
}
7577
}
7678

@@ -163,7 +165,7 @@ def call(Map pipelineParams = [:]) {
163165
${analysisParameters} \
164166
-Dsonar.core.codeCoveragePlugin=jacoco \
165167
-Dsonar.projectKey=${pipelineParams.sonar.projectKey} \
166-
-Dsonar.exclusions=${pipelineParams.sonar.exclusions}
168+
-Dsonar.exclusions=${pipelineParams.sonar.exclusions} -Dsonar.test.exclusions=${pipelineParams.sonar.testExclusions}
167169
"""
168170
}
169171
}

vars/continuousIntegrationPipeline.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
- `enable`: Enables/Disables the Sonar scan steps. Default value: `false`.
1010
- `tokenId`: Jenkins Credentials Id of the corresponding Sonar token used for authentication. It is provided by Eclipse Foundation devops when the Sonar project is created and its credentials are loaded in the Jenkins instance. **Must be set if Sonar scan is enabled**
1111
- `projectKey`: Sonar unique identifier for the project. Can be found on the SonarQube instance. **Must be set if Sonar scan is enabled**
12-
- `exclusions`: Path to be excluded from Sonar analysis. **Must be set if Sonar scan is enabled**
12+
- `exclusions`: Source path to be excluded from Sonar analysis. Default value: `*.xml`. **Must be set if Sonar scan is enabled**
13+
- `testExclusions`: Test path to be excluded from Sonar analysis. Default value: `**/*.java,*.xml`. **Must be set if Sonar scan is enabled**
1314
- [Optional] `toolchain`: The toolchain to be used for the build. Default value: `[ jdk: "temurin-jdk17-latest", maven: "apache-maven-3.9.6" ]`. Available values:
1415
- **jdk**: `temurin-jdk17-latest`
1516
- **maven**: `apache-maven-3.9.6`
@@ -25,7 +26,6 @@ node {
2526
enable: true,
2627
projectKey: "eclipse-kura_kura-something",
2728
tokenId: "sonarcloud-token-kura-something"
28-
exclusions: "tests/**/*.java"
2929
],
3030
)
3131
}

0 commit comments

Comments
 (0)