User Guide: CI/CD 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

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-ci.properties file to the root of your repository. A full sample version of this 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
      sourceCodePath: .
      sourceCodeLanguage: java
      dsmOutputFormat: json
      clusteringOutputFormat: json
      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-ci.properties
        tags:
          - dv8
        artifacts:
          name: "archreport-${CI_COMMIT_SHORT_SHA}"
          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

        This approach can run the DV8 job on a machine within your organization or on GitLab's cloud. Currently, this requires a running license server. You can contact us at support@archdia.com for more information.

        1. From your GitLab repository, navigate to Settings > CI/CD > Variables. Add a new variable called DV8_RELAY_URL containing the URL to your DV8 license server.
        2. Add an .archreport-ci.properties file to the root of your repository. A full sample version of this 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
          sourceCodePath: .
          sourceCodeLanguage: java
          dsmOutputFormat: json
          clusteringOutputFormat: json
          revisionHistoryType: git
          1. Add a .gitlab-ci.yml to the root of your repository if it does not already exist. Below is the recommended way to specify the DV8 job. This will run archreport on your repository using the dv8-console image.
            dv8:
              image: archdia/dv8-console:5.1.0
              script:
                - dv8-console arch-report -paramsFile .archreport-ci.properties
              artifacts:
                name: "archreport-${CI_COMMIT_SHORT_SHA}"
                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.