How to organize full build pipeline with Gulp, Maven and Jenkins, all the way to integration tests?

前端 未结 4 528
悲哀的现实
悲哀的现实 2020-12-12 21:23

I have a project that has:

  • JS client with somewhat interesting build process. That includes compiling CSS, catenating and minifying JS and CSS, generating and
相关标签:
4条回答
  • 2020-12-12 21:26

    This project is about 2 years old but it does a lot of what you are looking for.

    https://github.com/pankajtandon/PointyPatient/blob/master/pointy-web/pom.xml

    Do checkout the parent pom which basically runs all the sub-projects together right from the web to the domain to the repo and fails if any (Jasmine or SpringMVC or SpringServices tests) fail. And it build a war for the server side deployment too.

    This was pre-protractor, so that would be a nice addition. Altho the frontend maven plugin looks like the tool for the job now.

    HTH Pankaj

    0 讨论(0)
  • 2020-12-12 21:32

    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>
    

    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.

    0 讨论(0)
  • 2020-12-12 21:40

    I'd try to build kind of poor-man's-pipeline.

    1. Let grunt/gulp do its work first (process assets, run frontend tests etc - prepare artifacts to be included in WAR). Fail entire build when this step fails (assets generation or tests).

    2. Run regular maven build producing WAR file with assets created in step 1. It will run own set of tests with just regular WAR file. Doesn't need to know about grunt/gulp things.

    You'll then have two places where e.g. tests are run (frontend, run by grunt/gulp and backend by maven) but configuring correct reporters will let CI servers to detect all of them (we use TeamCity and it handles it fine).

    Script it up a bit and it should be better than calling node via antrun multiple times. Alternatively you can run first step from within maven build, but it may be hard to control stuff.

    0 讨论(0)
  • 2020-12-12 21:44

    I'm just going to use this as a stub because I've been looking to do a similar thing, and I will return later to enrich my answer. In the meantime you should look up JHipster. Though they have a much larger stack, and their stack is already built, they are essentially doing what I think you want within their build process.

    Though I do not agree completely with their build process I will return to explain why and what I am doing in projects I am currently working on.

    0 讨论(0)
提交回复
热议问题