Creating a Jenkins pipeline using JHipster

We can create the Jenkinsfile for our project using the ci-cd sub-generator from JHipster:

  1. In a terminal, navigate to the online-store folder first. Now run the following command:
> jhipster ci-cd
  1. You will be asked to select from a list of options as follows:
Welcome to the JHipster CI/CD Sub-Generator
? What CI/CD pipeline do you want to generate? (Press <space> to select, <a> to toggle all, <i> to inverse selection)
>Jenkins pipeline
◯ Travis CI
◯ GitLab CI
◯ CircleCI
  1. Let's select Jenkins pipeline from it. Next, we will have an option to choose additional stages:
? What CI/CD pipeline do you want to generate? Jenkins pipeline
? Jenkins pipeline: what tasks/integrations do you want to include?
>◯ Perform the build in a Docker container
◯ Analyze code with Sonar
◯ Send build status to GitLab
◯ Build and publish a Docker image
  1. Let's skip this, as we won't be needing these for now, and proceed. Next, we will be asked if we need to automatically deploy to Heroku from our CI/CD pipeline:
? What CI/CD pipeline do you want to generate? Jenkins pipeline
? Jenkins pipeline: what tasks/integrations do you want to include?
? Deploy to heroku?
>In Jenkins pipeline
  1. Let's choose this option as we will need it later. Once the option is selected JHipster will generate the files and log the following output on the console.
   create Jenkinsfile
create src/main/docker/jenkins.yml
create src/main/resources/idea.gdsl
Congratulations, JHipster execution is complete!
If you want to use Travis instead of Jenkins you can do so by choosing the Travis option and then publishing the repository to GitHub as a public repository. Once published go to https://github.com/<username>/<repoName>/settings/installations and add Travis CI as a service and follow the instructions. You can now see automated builds when you make commits. Refer to https://docs.travis-ci.com/user/getting-started/ for details.

As you can see, we got a Jenkinsfile generated at the root and Docker image for Jenkins created in the src/main/docker directory. We also got an idea.gdsl file, which is used by IntelliJ Idea for autocompletion.