Page tree
Skip to end of metadata
Go to start of metadata

Last updated: Jan 08, 2020 15:04

CircleCI is a cloud-based CI/CD tool. An on-premises solution is also available. CircleCI automatically runs your build in a clean container or virtual machine, allowing you to test every commit. It supports any language that builds on Linux, Windows, or macOS, including C++, Javascript, .NET, PHP, Python, and Ruby.

This section guides you through the process of creating a CircleCI account and integrating it with a Maven project. A sample project is available here: 

To integrate CircleCI with a Maven project:

  1. Follow the CircleCI instructions here to sign up and try CircleCI for free:
    You sign up with your GitHub or Bitbucket account.
  2.  Perform the instructions provided in the file.
  3. To help CircleCI webhooks to listen for git updates, create the following in the root of your repository:
    • A folder called .circleci
    • A .yml file called config.yml
      The file path to this file should be: .circleid/config.yml
  4. In the config.yml file, add the following code. The content is self-explanatory.

    Config file content
    version: 2.1 # use CircleCI 2.1
    jobs: # a collection of steps
      build: # runs not using Workflows must have a `build` job as entry point
        working_directory: ~/MavenCircleCISample # directory where steps will run
        docker: # run the steps with Docker
          - image: circleci/openjdk:8-jdk-stretch # ...with this image as the primary container; this is where all `steps` will run
        steps: # a collection of executable commands
            - checkout # check out source code to working directory
            - restore_cache: # restore the saved cache after the first run or if `pom.xml` has changed
                # Read about caching dependencies:
                key: MavenCircleCISample-{{ checksum "pom.xml" }}
            - run: mvn dependency:go-offline # gets the project dependencies
            - save_cache: # saves the project dependencies
                  - ~/.m2
                key: MavenCircleCISample-{{ checksum "pom.xml" }}
            - run: mvn clean install -B -DcloudName=${cloudName}  -DsecurityToken=${securityToken} -Dreportium-job-name=${CIRCLE_PROJECT_REPONAME} -Dreportium-job-number=${CIRCLE_BUILD_NUM} -Dreportium-job-branch=${CIRCLE_BRANCH} -Dreportium-tags="test"
            - run: echo "Perfecto Suite Report- https://${cloudName}[0]=${CIRCLE_PROJECT_REPONAME}&jobNumber[0]=${CIRCLE_BUILD_NUM}"
            - store_test_results: # uploads the test metadata from the `target/surefire-reports` directory so that it can show up in the CircleCI dashboard. 
            # Upload test results for display in Test Summary:
                path: target/surefire-reports
    workflows: # The following yaml will schedule this maven build operation to run every day at 12:00am UTC
      version: 2
          - build
          - schedule:
              cron: "0 0 * * *"
                    - master      
          - build


    • Replace MavenCircleCISample with your project folder name.
    • The run command contains the Maven goals. You can tweak them as needed for your project.
    • For enhanced security and as a best practice, we add the cloudName (for example demo) and the Perfecto security Token as environment variables to our project. Follow the steps here to set up environment variables for your project. For information on security tokens, see Generate security tokens.

       Click to view image
    • CircleCI automatically builds for every commit and performs a nightly execution at 12:00am UTC due to a nightly trigger workflow.
    • You can add CircleCI status badges to your file. For example, ![CircleCI status]( "CircleCI status" will showcase the current build status of CircleCI in GitHub. For instructions, see here.

       Click to view image