feat: split runNodeTest into runNodeInstall + runNodeTest, add lcov to sonar
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
13
vars/runNodeInstall.groovy
Normal file
13
vars/runNodeInstall.groovy
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Runs npm install inside current container.
|
||||||
|
* Must be called inside container('node') block.
|
||||||
|
*
|
||||||
|
* config keys (all optional):
|
||||||
|
* workDir - directory to run in, default: '.'
|
||||||
|
*/
|
||||||
|
def call(Map config = [:]) {
|
||||||
|
def workDir = config.workDir ?: '.'
|
||||||
|
dir(workDir) {
|
||||||
|
sh 'npm install'
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Runs npm install + npm test inside current container.
|
* Runs npm test inside current container. Expects npm install already done.
|
||||||
* Must be called inside container('node') block.
|
* Must be called inside container('node') block.
|
||||||
*
|
*
|
||||||
* config keys (all optional):
|
* config keys (all optional):
|
||||||
@@ -11,7 +11,6 @@ def call(Map config = [:]) {
|
|||||||
def testCmd = config.testCmd ?: 'test'
|
def testCmd = config.testCmd ?: 'test'
|
||||||
|
|
||||||
dir(workDir) {
|
dir(workDir) {
|
||||||
sh 'npm install'
|
|
||||||
sh "npm ${testCmd}"
|
sh "npm ${testCmd}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
* credId (optional) - Jenkins secret-text credential id, default: sonarqube-token
|
* credId (optional) - Jenkins secret-text credential id, default: sonarqube-token
|
||||||
* sources (optional) - sources to scan, default: .
|
* sources (optional) - sources to scan, default: .
|
||||||
* exclusions (optional) - comma-separated paths to exclude
|
* exclusions (optional) - comma-separated paths to exclude
|
||||||
|
* lcovReport (optional) - path to lcov.info for coverage, default: coverage/lcov.info
|
||||||
*/
|
*/
|
||||||
def call(Map config) {
|
def call(Map config) {
|
||||||
def projectKey = config.projectKey
|
def projectKey = config.projectKey
|
||||||
@@ -18,6 +19,7 @@ def call(Map config) {
|
|||||||
def credId = config.credId ?: 'sonarqube-token'
|
def credId = config.credId ?: 'sonarqube-token'
|
||||||
def sources = config.sources ?: '.'
|
def sources = config.sources ?: '.'
|
||||||
def exclusions = config.exclusions ?: ''
|
def exclusions = config.exclusions ?: ''
|
||||||
|
def lcovReport = config.lcovReport ?: 'coverage/lcov.info'
|
||||||
|
|
||||||
def exclusionsArg = exclusions ? "-Dsonar.exclusions=${exclusions}" : ''
|
def exclusionsArg = exclusions ? "-Dsonar.exclusions=${exclusions}" : ''
|
||||||
|
|
||||||
@@ -28,6 +30,7 @@ def call(Map config) {
|
|||||||
-Dsonar.sources=${sources} \
|
-Dsonar.sources=${sources} \
|
||||||
-Dsonar.host.url=${sonarUrl} \
|
-Dsonar.host.url=${sonarUrl} \
|
||||||
-Dsonar.token=\${SONAR_TOKEN} \
|
-Dsonar.token=\${SONAR_TOKEN} \
|
||||||
|
-Dsonar.javascript.lcov.reportPaths=${lcovReport} \
|
||||||
${exclusionsArg}
|
${exclusionsArg}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user