简体   繁体   English

是否可以在 Jenkins 的构建后操作中执行 JavaScript 脚本?

[英]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.

相关问题 如何在构建后的步骤中使JavaScript App(jsproj)生成APPX - How to make JavaScript App (jsproj) generate APPX in post-build step Google Closure * .bat用于后期构建吗? - Google Closure *.bat for post-build? 在Visual Studio 2013中,如何在构建后步骤中缩小Javascript和CSS - In Visual Studio 2013, how do I minify Javascript and CSS in the post-build step 以文本形式构建JavaScript链,但以脚本形式执行 - Build javascript chain as text but execute as script 可以在PHP图像渲染脚本上执行javascript吗? - Possible to execute javascript on PHP image rendering script? Visual Studio:将jsmin作为生成后事件运行 - Visual Studio: Running jsmin as a post-build event VS.NET:在Web项目中执行构建后步骤 - VS.NET: Doing a post-build step in a web project 是否可以从javascript函数的调用中执行request.getRequestDispatcher? - Is it possible to execute the request.getRequestDispatcher from the post call of a javascript function? Visual Studio中的构建后Vue应用程序提供了“命令npm run build with code 1” - Post-build Vue application in Visual Studio gives a “The command npm run build exited with code 1” 是否可以在一个脚本标签中执行多个 javascript? - Is it possible to execute more than one javascript in one script tag?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM