How to Use MergeBase in: GitlabCI

Oscar van der Meer

Created Feb 23, 2022

How to Use MergeBase in: GitlabCI

231
1

Click on Set up CI/CD

Find the pipeline you'd like to integrate with MergeBase. Find the following button:

Click on Set up CI/CD
2

Click on Create new CI/CD pipeline

Click on Create new CI/CD pipeline
3

Click on 🚀 Let's do this! Paste the configuration from below or just use the mergebase stage.

#An Example CI Configuration



# This template uses jdk8 for verifying and deploying images
image: maven:3.3.9-jdk-8

variables:
  MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
  MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
  # auth header can be moved to CI variables
  MB_TOKEN: "[REDACTED]"

  # Your base URL is the location of your Dashboard homepage E.G https://trial.mergebase.com/cMfiVsjna. 
  MB_API_URL: "[mergebase-base-url]/api/update/clt/mergebase.jar"


# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
  paths:
    - .m2/repository

# You can add MergeBase as a new stage for source code analysis, or add the mergebase script at the end of the build step for binary analysis
stages:
  - build
  - mergebase
  - deploy

mergebase:
  stage: mergebase
  script:
    - 'wget --header="X-Authorization:$MB_TOKEN" $MB_API_URL'
    - java -jar mergebase.jar --name=TestPipeline ./pom.xml 

build:
  stage: build
  script:
    - mvn $MAVEN_CLI_OPTS install

# Replace with your deployment steps
deploy:
  stage: deploy
  script: echo "deploy"

Click on 🚀 Let's do this! Paste the configuration from below or just use the mergebase stage.
4

Grab your MergeBase Customer Token

Go to the MergeBase dashboard and click on "Settings"

Grab your MergeBase Customer Token
5

Find your Customer Token here

Copy this token for your GitlabCI script

Find your Customer Token here
6

Add your customer token from the previous step!

Make sure the value is surrounded by double quotes. At this point you can also

Add your customer token from the previous step!
7

Click on Commit changes

Make any other changes to your pipeline as necessary. See https://docs.gitlab.com/ee/ci/ for full Gitlab Documentation.

Click on Commit changes
8

Click on Pipelines

Click on Pipelines
    s

Mergebase

3 Steps
9

Click on Run pipeline

Click on Run pipeline
10

Click on master

Select the target branch

Click on master
11

Click on Run pipeline

Click on Run pipeline
    g

Gitlab

1 Step
12

Head back to the MergeBase dashboard

As you can see, your project has been scanned and you can view the full report for your application.

Head back to the MergeBase dashboard
Well done!
Create how-to guides like this in a snap. Get Tango now.