如何在构建Jenkins之前运行脚本shell(How to run script shell before building on Jenkins)

编程入门 行业动态 更新时间:2024-10-27 23:23:30
如何在构建Jenkins之前运行脚本shell(How to run script shell before building on Jenkins)

(Jenkins newb-newb-newbie here)你好。 我有一个部署在Jenkins上的Maven项目。 在这个项目中,我有一个集成测试,它依赖于.Net服务器才能正确运行。

问题是,当我试图在Jenkins上构建我的项目时,集成测试失败了,因为.Net没有启动...

我需要在构建项目之前执行shell脚本(用于启动.Net服务器)。 所以我的问题是:如何在从Jenkins构建之前启动我的项目脚本?

(Jenkins newb-newb-newbie here) Hi there. I have a Maven project, deployed on Jenkins . In this project, I have an integration test, which depends on a .Net server in order to be run correctly.

The problem is, when I'm trying to build my project on Jenkins, the integration test fails, because the .Net isn't launched...

I need to execute a shell script (for launhing the .Net server) before building my project. So my question is : how can I launch a script of my project before building from Jenkins?

最满意答案

这是一个构建步骤执行Windows批处理命令 ,您可以使用它来启动您的服务器。

您可能必须使用START才能在单独的进程中启动它,因此您的构建将继续,而无需等待服务器进程完成,并且您可能需要延迟一些以防服务器需要一些时间来解决,然后才能进行测试跑。

您可能还需要在测试完成后taskkill服务器,您可以在另一个执行Windows批处理命令构建步骤中使用tasklist和taskkill ,以及执行此操作的一些批处理魔法。

Theres a build step Execute Windows batch command which you could use to start your server.

You might have to use START to have it launched in a separate process, so your build continues without waiting for the server process to finish, and you might need to put in some delay in case your server needs some time to settle before your tests can run.

You might also need to kill your server after your tests are done, you might be able to use tasklistand taskkill in another Execute Windows batch command build step, and some batch magic to do this.

更多推荐

本文发布于:2023-07-09 16:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336761.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   如何在   Jenkins   shell   script

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!