Detekt.xml report could not be generated in gitlab pipeline
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Dear Experts, I dont know if this place is right address to solve my problem. But I still want to try my chance. We want to use detekt library to provide static code analysis in our android project. But detekt does not work as expected in pipeline.
Expected Behavior
detekt.xml report should be always generated in gitlab pipeline.
Observed Behavior
detekt.xml report is generated only when detekt job passed successfully in gitlab pipeline. if detekt job fails, report could not be generated. What I mean by "failing" is when there is such a warning, detekt job fails as you know.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:detekt'.
> Analysis failed with 2 weighted issues.
When I run the same task in Android studio, detek job fails because of weighted issues and I can view the xml report in build directory. For the same scenario, in gitlab pipeline, report could not be generated because job fails. So there is no artifact for report.
Steps to Reproduce
gitlab-ci.yml file:
detekt:
stage: codequality
script:
- ./gradlew detekt
artifacts:
paths:
- app/build/reports
detekt.gradle
apply plugin: "io.gitlab.arturbosch.detekt"
detekt {
toolVersion = Versions.detekt
config = files("../config/detekt/detekt.yml")
buildUponDefaultConfig = true
}
tasks.named("detekt").configure {
reports {
xml.required.set(true)
xml.outputLocation.set(file("build/reports/detekt.xml"))
html.required.set(true)
html.outputLocation.set(file("$buildDir/reports/detekt.html"))
txt.required.set(false)
sarif.required.set(false)
md.required.set(false)
}
}
Context
We need detekt.xml reports for our code review processes and sonarqube reports.
Your Environment
detekt: 1.21.0 gradle: 7.5.1 gitlab-runner 14.10.1