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.
- 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. - Install GitLab Runner on that same machine using the directions available here.
- From your GitLab repository, navigate to Settings > CI/CD > Runners and click "New project runner".
- Enter a single tag:
dv8
and leave everything else to their default settings. Click "Create runner". - Follow the directions to register your runner.
- Add an
archreport.properties
file to the root of your repository. A samplearchreport.properties
file is included in the installation package, located in thedv8-explorer/sample-configurations
folder. Below is a minimal example:
outputFolder: archreport
projectName: <YOUR_PROJECT_NAME_HERE>
sourceType: code
sourceCodeLanguage: java
revisionHistoryType: git
- 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
- 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.
- From your GitLab repository, navigate to Settings > CI/CD > Variables. Add two new variables:
LICENSE_KEY
andACTIVATION_CODE
containing your license key and activation code respectively. Ensure both have "Masked" visibility. - Add an
archreport.properties
file to the root of your repository. A samplearchreport.properties
file is included in the installation package, located in thedv8-explorer/sample-configurations
folder. Below is a minimal example:
outputFolder: archreport
projectName: <YOUR_PROJECT_NAME_HERE>
sourceType: code
sourceCodeLanguage: java
revisionHistoryType: git
- 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
- After your next commit, you will be able to download the archreport for your GitLab project in Build > Jobs > Download artifacts.