DEV Community

Kengo TODA
Kengo TODA

Posted on

2 4

Build stage on Travis CI

Today I found a Travis CI blog post regarding build stage on Travis CI. Now it goes GA so we all can enjoy this feature.

Here is the my PR to introduce build stage. In my feeling, it has one good point:

No more if in analysis and deploy part

When I run analysis like SonarCloud, it was necessary to limit target JVM & environment variable to make PR page easy to read. For example, here is a .travis.yml snippet that runs analysis only with specific condition:

jdk:
  - oraclejdk8
  - oraclejdk9
script:
  - ./mvnw org.jacoco:jacoco-maven-plugin:prepare-agent verify -B
  - if [[ $TRAVIS_JDK_VERSION == "oraclejdk8" ]]; then ./mvnw sonar:sonar -B; fi
Enter fullscreen mode Exit fullscreen mode

In case of build stage, script runs with the first value in env, jdk and others by default. So we can remove if from .travis.yml:

jdk:
  - oraclejdk8
  - oraclejdk9
script:
  - ./mvnw verify -B
jobs:
  include:
    - stage: analysis
      script:
        - ./mvnw org.jacoco:jacoco-maven-plugin:prepare-agent verify sonar:sonar -B
Enter fullscreen mode Exit fullscreen mode

One point, is that, each build stage and job doesn't share generated files. So here we need to run verify phase even in analysis stage, to generate analysis targets (.class file in this case).

This merit works even to deploy phase. This feature should reduce complexity in our .travis.yml.

That's all. Enjoy hacking with Travis CI!

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay