mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
60fa1d5bbf
This change adds linting support for Java-/TypeScript projects based on the checkDefaultLint and checkUserLint steps from Cloud SDK Pipeline. Following options are supported: 1. Define a linting script named ci-lint in the package.json file(s) of the project 2. Provide a configuration for ESLint as part of the project 3. If none of the above: ESLint is executed with a general purpose configuration. Co-authored-by: Daniel Kurzynski <daniel.kurzynski@sap.com>
33 lines
1.1 KiB
Groovy
33 lines
1.1 KiB
Groovy
import com.sap.piper.BuildTool
|
|
import com.sap.piper.DownloadCacheUtils
|
|
import groovy.transform.Field
|
|
import hudson.AbortException
|
|
|
|
import static com.sap.piper.Prerequisites.checkScript
|
|
|
|
@Field String STEP_NAME = getClass().getName()
|
|
@Field String METADATA_FILE = 'metadata/npmExecuteLint.yaml'
|
|
|
|
//Metadata maintained in file project://resources/metadata/npmExecuteLint.yaml
|
|
|
|
void call(Map parameters = [:]) {
|
|
final script = checkScript(this, parameters) ?: this
|
|
parameters = DownloadCacheUtils.injectDownloadCacheInParameters(script, parameters, BuildTool.NPM)
|
|
|
|
try {
|
|
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, [])
|
|
} catch (Exception exception) {
|
|
error("Linter execution failed. Please examine the reports which are also available in the Jenkins user interface.")
|
|
}
|
|
finally {
|
|
visualizeLintingResults(script)
|
|
}
|
|
}
|
|
|
|
private visualizeLintingResults(Script script) {
|
|
recordIssues blameDisabled: true,
|
|
enabledForFailure: true,
|
|
aggregatingResults: false,
|
|
tool: script.checkStyle(id: "lint", name: "Lint", pattern: "*lint.xml")
|
|
}
|