如何使用 Gulp、Maven 和 Jenkins 组织完整的构建管道,一直到集成测试? [英] How to organize full build pipeline with Gulp, Maven and Jenkins, all the way to integration tests?

查看:21
本文介绍了如何使用 Gulp、Maven 和 Jenkins 组织完整的构建管道,一直到集成测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目:

  • 具有一些有趣的构建过程的 JS 客户端.这包括编译 CSS、连接和缩小 JS 和 CSS、生成和处理 HTML 以及其他一些步骤.Grunt 或 Gulp 等 Node 工具在这方面非常出色.
  • Java 服务器,它是部署在 Tomcat 上的 WAR.它包括这些资产以及所有 Java 代码.它有各种测试:单元测试、可以实例化 DAO 并与 DB 对话的集成测试,以及实际与 Tomcat 上运行的应用对话的端到端 API 测试.
  • 使用 Protractor 进行端到端测试.如果您不熟悉,它是另一个封装 Selenium 的 Node 工具.

如何以一种理智、稳健和自动化的方式组织整个过程?

How can I organize this whole process in a sane, robust, and automated way?

我目前拥有的是 Gulp 和 Maven,Maven 基本上拥有整个过程.

What I have at the moment is Gulp and Maven, with Maven basically owning the whole process.

  1. 它使用 antrun(doh,第三个构建工具!)在 generate-sources 中调用 Gulp 资产生成.
  2. 它运行常规的 Java 构建.
  3. 它在预集成测试中使用我的 WAR 启动 Tomcat.
  4. 它运行 Java E2E 测试,与带有故障安全插件的 tomcat 通信.
  5. 它再次使用 antrun 调用 Gulp,这次是为了运行 Protractor 测试.
  6. 它会在集成后测试中关闭 Tomcat.
  7. 应该是在verify中验证测试结果.

那种作品,除了Maven通常非常死板,我觉得我走得太远了.使用 antrun 调用 Gulp 是一个丑陋的技巧.很难控制这些步骤之间的依赖关系并监控它们的结果.在同一阶段很难控制事物的顺序.Failsafe verify 似乎不处理 Gulp 生成的外部 JUnit 报告文件.我可以继续.

That kind of works, except for that Maven is generally very rigid and I feel I'm taking it too far. Using antrun to call Gulp is an ugly trick. It's very hard to control dependencies between these steps and monitor their outcomes. It's hard to control order of things in the same phase. Failsafe verify does not seem to process the external JUnit report files that Gulp generates. I could go on.

我想知道我是否应该在我的构建服务器 (Jenkins) 中做更多的事情,也许使用构建管道或参数化触发器 - 但我从来没有做过,我不确定这是否真的更好.

I wonder if I should do more in my build server (Jenkins), maybe using a build pipeline or parameterized triggers - but I've never done it and I'm not sure if that's really better.

那么,您将如何实施它?

So, how would you implement it?

推荐答案

根据我的经验,前端 Maven 插件无疑是此类构建/部署过程的最佳插件.https://github.com/eirslett/frontend-maven-plugin.这就是我将它用于 Grunt 的方式,但它也支持 Gulp.

In my experience, the frontend maven plugin is far and away the best plugin for this type of build/deploy process. https://github.com/eirslett/frontend-maven-plugin . This is how i use it for Grunt but it supports Gulp just as well.

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <version>...</version>

    <!-- optional -->
    <configuration>
        <workingDirectory>src/main/frontend</workingDirectory>
    </configuration>

   <execution>
    <id>grunt build</id>
    <goals>
        <goal>grunt</goal>
    </goals>

    <!-- optional: the default phase is "generate-resources" -->
    <phase>generate-resources</phase>

    <configuration>
        <!-- optional: if not specified, it will run Grunt's default
        task (and you can remove this whole <configuration> section.) -->
        <arguments>build</arguments>
    </configuration>
</execution>
</plugin>

需要注意的一件事是它会为正在运行的系统下载节点,因此如果您的构建服务器上有不同的操作系统,则需要确保这是您签入的版本版本控制,你的本地版本(对我来说是 OSX)必须在你的项目本地维护.

One thing to be aware of it is will download node for the system it is being run on, so if you have a different OS on your build server, you'll need to make sure that is the version you have checked into version control, your local version (for me OSX) will have to be maintained local to your project.

这篇关于如何使用 Gulp、Maven 和 Jenkins 组织完整的构建管道,一直到集成测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆