Files
homelab-jenkins-shared-libs/vars/runNodeTest.groovy
2026-04-26 13:43:49 +07:00

18 lines
443 B
Groovy

/**
* Runs npm install + npm test inside current container.
* Must be called inside container('node') block.
*
* config keys (all optional):
* workDir - directory to run in, default: '.'
* testCmd - npm script to run, default: 'test'
*/
def call(Map config = [:]) {
def workDir = config.workDir ?: '.'
def testCmd = config.testCmd ?: 'test'
dir(workDir) {
sh 'npm install'
sh "npm ${testCmd}"
}
}