【问题标题】:How to make Jenkins to build an AngularJS app from one GIT Repository and execute tests from a separate Repository如何让 Jenkins 从一个 GIT 存储库构建 AngularJS 应用程序并从单独的存储库执行测试
【发布时间】:2019-02-13 16:37:50
【问题描述】:

我正在尝试为我们的测试项目实施 Jenkins。我预期的工作流程如下:

  1. Jenkins 将在开发人员将代码推送到 GIT Repo(NPM 启动)中的应用程序时构建应用程序 (AngularJS)
  2. Jenkins 将启动应用程序 ( /> ng serve) -- 这将在 localhost:4200 启动服务器

  3. Jenkins 将切换到测试脚本存储库

  4. Jenkins 将开始测试执行
  5. Jenkins 将在执行测试后关闭服务器

我的问题是:

一个。当 Jenkins 在第 2 步结束时构建时。它正在创建一个将继续运行的服务器实例。在这种情况下,命令窗口专用于服务器,它不接受任何命令。那么如何让 jenkins 移动到测试目录并开始测试应用程序呢?

b.在流程结束时,如何在不手动输入“Ctl+C”的情况下通过 Jenkins 停止服务器?

【问题讨论】:

  • 你的设置太疯狂了。通常,您希望您的测试在您的应用程序相同的存储库中,并使用命令启动它们,而不是构建和提供应用程序

标签: angularjs jenkins continuous-integration jenkins-pipeline


【解决方案1】:

分离你的构建。 一个管道是从主仓库构建的。 第二个管道是从测试存储库中获取并运行测试。 第一条管道

node("main") {
   stage("build") {
      git url: "https://github.com/your project repo",  credentialsId: "[credentials if need or avoid this param]", branch: "branch name"
       rest of steps
   }

   stage("Test") {
      build job:"TestJob", wait: true
   }
}

和TestJob工作代码:

node("main") {
   stage("build") {
      git url: "https://github.com/your test repo",  credentialsId: "[credentials if need or avoid this param]", branch: "branch name"
       rest steps to test app
    } 
 }

您可以查看 documentation 的运行构建步骤

【讨论】:

    猜你喜欢
    • 2018-05-12
    • 2012-02-13
    • 1970-01-01
    • 2013-05-09
    • 1970-01-01
    • 1970-01-01
    • 2020-10-25
    • 1970-01-01
    • 2010-10-30
    相关资源
    最近更新 更多