在 Jenkins 上构建之前如何 运行 脚本 shell

How to run script shell before building on Jenkins

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

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

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

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

您可能必须使用 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 以防您的服务器需要一些时间来稳定您的测试 运行。

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