Skip to content

Commit

Permalink
chore: switch to new parameter name (#4968)
Browse files Browse the repository at this point in the history
* chore: switch to new parameter name

Since warnings-ng plugin version 11 the blameDisabled parameter
has been replaced by skipBlames.
To be compatible with Jenkinsfile Runner we put the recordIssues step
into a try/catch, so no exception is thrown and the build fails.

* docs: improve wording

Co-authored-by: Srinikitha Kondreddy <[email protected]>

---------

Co-authored-by: Srinikitha Kondreddy <[email protected]>
  • Loading branch information
o-liver and srinikitha09 authored Jun 28, 2024
1 parent 06df2d4 commit fe2e4e7
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 29 deletions.
2 changes: 1 addition & 1 deletion documentation/docs/extensibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def call(Map parameters) {
goals: ['checkstyle:checkstyle'],
)
recordIssues blameDisabled: true,
recordIssues skipBlames: true,
enabledForFailure: true,
aggregatingResults: false,
tool: checkStyle()
Expand Down
2 changes: 1 addition & 1 deletion resources/default_pipeline_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ steps:
parserPattern: '\[(INFO|WARNING|ERROR)\] (.*) \(([^) ]*)\/([^) ]*)\)'
parserScript: 'return builder.guessSeverity(matcher.group(1)).setMessage(matcher.group(2)).setModuleName(matcher.group(3)).setType(matcher.group(4)).buildOptional()'
recordIssuesSettings:
blameDisabled: true
skipBlames: true
enabledForFailure: true
seleniumExecuteTests:
buildTool: 'npm'
Expand Down
2 changes: 1 addition & 1 deletion test/groovy/PiperPublishWarningsTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class PiperPublishWarningsTest extends BasePiperTest {
assertThat(warningsParserSettings, hasKey('script'))
assertThat(warningsPluginOptions, allOf(
hasEntry('enabledForFailure', true),
hasEntry('blameDisabled', true)
hasEntry('skipBlames', true)
))
assertThat(warningsPluginOptions, hasKey('tools'))

Expand Down
11 changes: 8 additions & 3 deletions vars/checksPublishResults.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ void call(Map parameters = [:]) {
def report(tool, settings, doArchive){
def options = createOptions(settings).plus([tools: [tool]])
echo "recordIssues OPTIONS: ${options}"
// publish
recordIssues(options)
try {
// publish
recordIssues(options)
} catch (e) {
echo "recordIssues has failed. Possibly due to an outdated version of the warnings-ng plugin."
e.printStackTrace()
}
// archive check results
archiveResults(doArchive && settings.get('archive'), settings.get('pattern'), true)
}
Expand All @@ -149,7 +154,7 @@ def archiveResults(archive, pattern, allowEmpty){
@NonCPS
def createOptions(settings){
Map result = [:]
result.put('blameDisabled', true)
result.put('skipBlames', true)
result.put('enabledForFailure', true)
result.put('aggregatingResults', false)

Expand Down
25 changes: 15 additions & 10 deletions vars/hadolintExecute.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,21 @@ def issuesWrapper(Map parameters = [:], Script script, Closure body){
try {
body()
} finally {
recordIssues(
blameDisabled: true,
enabledForFailure: true,
aggregatingResults: false,
qualityGates: config.qualityGates,
tool: checkStyle(
id: config.reportName,
name: config.reportName,
pattern: config.reportFile
try {
recordIssues(
skipBlames: true,
enabledForFailure: true,
aggregatingResults: false,
qualityGates: config.qualityGates,
tool: checkStyle(
id: config.reportName,
name: config.reportName,
pattern: config.reportFile
)
)
)
} catch (e) {
echo "recordIssues has failed. Possibly due to an outdated version of the warnings-ng plugin."
e.printStackTrace()
}
}
}
27 changes: 18 additions & 9 deletions vars/mavenExecuteStaticCodeChecks.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,27 @@ private showIssues(Script script) {
Map configuration = ConfigurationLoader.stepConfiguration(script, STEP_NAME)
// Every check is executed by default. Only if configured with `false` the check won't be executed
if (!(configuration.spotBugs == false)) {
recordIssues(blameDisabled: true,
enabledForFailure: true,
aggregatingResults: false,
tool: spotBugs(pattern: '**/target/spotbugsXml.xml'))

try {
recordIssues(skipBlames: true,
enabledForFailure: true,
aggregatingResults: false,
tool: spotBugs(pattern: '**/target/spotbugsXml.xml'))
} catch (e) {
echo "recordIssues has failed. Possibly due to an outdated version of the warnings-ng plugin."
e.printStackTrace()
}
ReportAggregator.instance.reportStaticCodeExecution(QualityCheck.FindbugsCheck)
}
if (!(configuration.pmd == false)) {
recordIssues(blameDisabled: true,
enabledForFailure: true,
aggregatingResults: false,
tool: pmdParser(pattern: '**/target/pmd.xml'))
try {
recordIssues(skipBlames: true,
enabledForFailure: true,
aggregatingResults: false,
tool: pmdParser(pattern: '**/target/pmd.xml'))
} catch (e) {
echo "recordIssues has failed. Possibly due to an outdated version of the warnings-ng plugin."
e.printStackTrace()
}
ReportAggregator.instance.reportStaticCodeExecution(QualityCheck.PmdCheck)
}
}
13 changes: 9 additions & 4 deletions vars/npmExecuteLint.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ void call(Map parameters = [:]) {
}

private visualizeLintingResults(Script script) {
recordIssues blameDisabled: true,
enabledForFailure: true,
aggregatingResults: false,
tool: script.checkStyle(id: "lint", name: "Lint", pattern: "*lint.xml")
try {
recordIssues skipBlames: true,
enabledForFailure: true,
aggregatingResults: false,
tool: script.checkStyle(id: "lint", name: "Lint", pattern: "*lint.xml")
} catch (e) {
echo "recordIssues has failed. Possibly due to an outdated version of the warnings-ng plugin."
e.printStackTrace()
}
}

0 comments on commit fe2e4e7

Please sign in to comment.