User Guide: CICD Integration: GitLab


DV8 User Guide 4.0 - GitLab CI/CD Integration

GitLab CI/CD Integration

There are two ways to integrate DV8 with GitLab for CI/CD: the manual approach and using Docker. Both methods allow you to run DV8’s archreport on each commit of your repository.

Option 1: Manual Integration

This approach will run the DV8 job on a machine within your organization.

  1. Install DV8 on a machine within your organization using the directions available here. Ensure that the PATH is updated so dv8-console is available from the terminal/command prompt.
  2. Install GitLab Runner on that same machine using the directions available here.
  3. From your GitLab repository, navigate to Settings > CI/CD > Runners and click "New project runner".
  1. Enter a single tag: dv8 and leave everything else to their default settings. Click "Create runner".
  2. Follow the directions to register your runner.
  3. Add an archreport.properties file to the root of your repository. A sample archreport.properties file is included in the installation package, located in the dv8-explorer/sample-configurations folder. Below is a minimal example:
    outputFolder: archreport
    projectName: <YOUR_PROJECT_NAME_HERE>
    sourceType: code
    sourceCodeLanguage: java
    revisionHistoryType: git
    1. Add a .gitlab-ci.yml to the root of your repository if it does not already exist. Below is a minimal example:
    dv8:
      script:
        - dv8-console arch-report -paramsFile archreport.properties
      tags:
        - dv8
      artifacts:
        paths:
          - archreport/
        expire_in: never
    
      1. After your next commit, you will be able to download the archreport for your GitLab project in Build > Jobs > Download artifacts.

      Option 2: Docker Integration (Experimental)

      This approach allows the DV8 job to run either on a machine within your organization or on GitLab’s cloud, using a DV8 Docker image from Docker Hub. The following description uses GitLab’s cloud.

      1. From your GitLab repository, navigate to Settings > CI/CD > Variables. Add two new variables: LICENSE_KEY and ACTIVATION_CODE containing your license key and activation code respectively. Ensure both have "Masked" visibility.
      2. Add an archreport.properties file to the root of your repository. A sample archreport.properties file is included in the installation package, located in the dv8-explorer/sample-configurations folder. Below is a minimal example:
        outputFolder: archreport
        projectName: <YOUR_PROJECT_NAME_HERE>
        sourceType: code
        sourceCodeLanguage: java
        revisionHistoryType: git
        1. Add a .gitlab-ci.yml to the root of your repository if it does not already exist. Below is a minimal example:
          dv8:
            image: jasonlefever/dv8-console
            script:
              - dv8-console license:activate -licenseKey $LICENSE_KEY -activationCode $ACTIVATION_CODE
              - dv8-console arch-report -paramsFile archreport.properties
            after_script:
              - dv8-console license:deactivate -activationCode $ACTIVATION_CODE
            artifacts:
              paths:
                - archreport/
              expire_in: never
          1. After your next commit, you will be able to download the archreport for your GitLab project in Build > Jobs > Download artifacts.