Setting up Continuous Integration
Setting up Continuous Integration (CI) for a JHipster application is harder than for a classic typical Spring MVC application because of the complexity associated with maintaining a build composed of 2 software stacks:
- the Java back-end code with Maven or Gradle
Each stack comes with its own dependency management (Maven artifacts, NPM packages) with potential conflicts to solve.
JHipster should support the following CI systems out of the box:
- Travis: refer to the Travis Documentation
- CircleCI: refer to the CircleCI Documentation
- GitLab CI: refer to the GitLab CI Documentation
Running the sub-generator
To generate these config files, run this command in your project folder:
Then answer all the questions.
What CI/CD pipeline do you want to generate ?
The CI/CD pipeline you want to generate:
- Jenkins pipeline
- Travis CI
- GitLab CI
Jenkins pipeline: what tasks/integrations do you want to include ?
The tasks/integrations you want to include in the Jenkins pipeline:
- Perform the build in a Docker container
- Analyze code with Sonar
- Send build status to Gitlab
- Build and publish a Docker image
Note: when you select Jenkins pipeline, a new
src/main/docker/jenkins.yml file will be generated.
So you can test Jenkins locally by running:
docker-compose -f src/main/docker/jenkins.yml up -d
What is the name of the Sonar server ?
Choose the name of the Sonar server.
What is the URL of the Docker registry ?
By default, you can use Docker Hub: https://registry.hub.docker.com
What is the Jenkins Credentials ID for the Docker registry ?
By default, you can use:
In GitLab CI perform the build in a docker container (hint: gitlab.com uses docker container)?
If you use a private GitLab CI, you can use directly the runners.
If you use official gitlab.com pipeline, you need to use Docker container.
Deploy to Heroku?
- In Jenkins pipeline
- In GitLab CI
- In CircleCI
You have to add the
HEROKU_API_KEY environment variable.