-
Notifications
You must be signed in to change notification settings - Fork 5
Setting up Continuous Integration
Setting up Continuous Integration (CI) for a JHipster application is more complex 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
- the JavaScript front-end with NodeJS, NPM or Yarn
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:
- Jenkins:
- [Setting up Jenkins 1]({{ site.url }}/setting-up-ci-jenkins1/)
- [Setting up Jenkins 2]({{ site.url }}/setting-up-ci-jenkins2/) (recommended)
- Travis: refer to the Travis Documentation
- GitLab CI: refer to the GitLab CI Documentation
- Azure Pipelines: refer to the Azure Pipelines Documentation
- GitHub Actions: refer to GitHub Actions Documentation
- CircleCI: refer to CircleCI Documentation
To generate these config files, run this command in your project folder:
jhipster ci-cd
Then answer all the questions.
The CI/CD pipeline you want to generate:
- Jenkins pipeline
- Azure Pipelines
- GitLab CI
- GitHub Actions
- Travis CI
- CircleCI
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
If Docker is installed, you can perform the build inside a Docker container.
In GitLab CI, perform the build in a docker container (hint: GitLab.com uses Docker container) ? (GitLab)
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.
If your Jenkins relies to a GitLab repository, you can send build status to GitLab. Your Jenkins must be correctly configured.
- Deploy your application to an Artifactory
- Analyze your code with Sonar
- Build and publish a Docker image
- Snyk: dependency scanning for security vulnerabilities (requires SNYK_TOKEN)
- Deploy to Heroku (requires HEROKU_API_KEY set on CI service)
- Would you like to enable the Cypress Dashboard (requires both CYPRESS_PROJECT_ID and CYPRESS_RECORD_KEY set on CI service)
- Artifactory: what is the ID of distributionManagement for snapshots ?
- Artifactory: what is the URL of distributionManagement for snapshots ?
- Artifactory: what is the ID of distributionManagement for releases ?
- Artifactory: what is the URL of distributionManagement for releases ?
- Sonar: what is the name of the Sonar server ?
Choose the name of the Sonar server, defined in your Jenkins Configuration.
- Sonar: what is the URL of the Sonar server ?
- Sonar: what is the Organization of the Sonar server ?
Here, you can choose to push your Sonar Analyze to SonarCloud.io.
In this case, you have to add the SONAR_TOKEN
environment variable.
- Docker: what is the URL of the Docker registry ?
By default, you can use Docker Hub: https://registry.hub.docker.com
- Docker: what is the Jenkins Credentials ID for the Docker registry ?
By default, you can use: docker login
- Docker: what is the Organization Name for the Docker registry ?
You have to add the SNYK_TOKEN
environment variable (check your Snyk account)
See full documentation at https://snyk.io/
You have to add the CYPRESS_PROJECT_ID
and the CYPRESS_RECORD_KEY
environment variables (check your Dashboard project)
You can disable the record by changing CYPRESS_ENABLE_RECORD
environment variable value to false.
See full the documentation at cypress.io/dashboard
- *Heroku: name of your Heroku Application ?
You have to add the HEROKU_API_KEY
environment variable.
Note: before using the deployment to Heroku, you need to use the [Heroku sub-generator]({{ site.url }}/heroku) locally. It will create all files needed by your Continuous Integration Tool.
Depending on your OS and where you pushed your project, you will probably need to make the wrapper executable before using a CI/CD.
If you use Maven:
chmod +x mvnw
git update-index --chmod=+x mvnw
If you use Gradle:
chmod +x gradlew
git update-index --chmod=+x gradlew
- Jenkins pipeline: you should use the Credentials plugin
- GitLab CI: read the documentation about secret-variables
- Travis CI: read the environment variables
- GitHub Actions: read the documentation about environment variables
- Azure Pipelines: read the documentation about predefined variables
- CircleCI: read the documentation about environment variables