Reputation: 67
I need to execute JavaScript script after ending of build. This script should use npm packages. Installed plugin as I have is:
post-build actions
. I've found something like execute script with option: add generic file script
. If I give here path to .js
script, will it work? Where should I place this script?
I can not check it easily because I do not have full control of this Jenkins instance.
Upvotes: 4
Views: 4734
Reputation: 5250
You can add you script to your npm package.json
scripts section and run it like:
post {
success {
script {
sh "npm run my-happy-script"
}
}
failure {
script {
sh "npm run my-sad-script"
}
}
}
Also you can select which directory to run from with the dir
command in your script block:
script {
dir("lib/another/directory") {
sh "node some-script.js"
}
}
Upvotes: 1