Setting up Continuous Integration Permalink to " 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

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:

Running the sub-generator Permalink to "Running the sub-generator"

To generate these config files, run this command in your project folder:

jhipster ci-cd

Then answer all the questions.

What CI/CD pipeline do you want to generate ? Permalink to "What CI/CD pipeline do you want to generate ?"

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

Would you like to perform the build in a Docker container ? (Jenkins / GitLab) Permalink to "Would you like to perform the build in a Docker container ? (Jenkins / GitLab)"

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) Permalink to "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.

Would you like to send build status to GitLab ? (Jenkins) Permalink to "Would you like to send build status to GitLab ? (Jenkins)"

If your Jenkins relies to a GitLab repository, you can send build status to GitLab. Your Jenkins must be correctly configured.

What tasks/integrations do you want to include ? Permalink to "What tasks/integrations do you want to include ?"

  • 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)

Deploy your application to an Artifactory (Jenkins / GitLab) Permalink to "Deploy your application to an Artifactory (Jenkins / GitLab)"

  • 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 ?

Analyze your code with Sonar Permalink to "Analyze your code with Sonar"

  • 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.

Build and publish a Docker image Permalink to "Build and publish a Docker image"

  • 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 ?

Snyk: dependency scanning for security vulnerabilities Permalink to "Snyk: dependency scanning for security vulnerabilities"

You have to add the SNYK_TOKEN environment variable (check your Snyk account)

See full documentation at https://snyk.io/

Cypress Dashboard: record your tests in a web application provided by Cypress Permalink to "Cypress Dashboard: record your tests in a web application provided by Cypress"

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

Deploy to Heroku Permalink to "Deploy to Heroku"

  • *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 locally. It will create all files needed by your Continuous Integration Tool.

Additional information Permalink to "Additional information"

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

Documentation about environment variables: Permalink to "Documentation about environment variables:"