[英]Is it possible to execute JavaScript script in post-build action in Jenkins?
I need to execute JavaScript script after ending of build.我需要在构建结束后执行 JavaScript 脚本。 This script should use npm packages.此脚本应使用 npm 个包。 Installed plugin as I have is: post-build actions
.我安装的插件是: post-build actions
。 I've found something like execute script with option: add generic file script
.我发现了类似 execute script with option: add generic file script
的东西。 If I give here path to.如果我在这里给出路径。 js
script, will it work? js
脚本,它会工作吗? Where should I place this script?我应该把这个脚本放在哪里?
I can not check it easily because I do not have full control of this Jenkins instance.我不能轻易检查它,因为我没有这个 Jenkins 实例的完全控制权。
You can add you script to your npm package.json
scripts section and run it like:您可以将脚本添加到 npm package.json
脚本部分并运行它,如下所示:
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:您还可以 select 使用脚本块中的dir
命令从哪个目录运行:
script {
dir("lib/another/directory") {
sh "node some-script.js"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.