How to Use MergeBase in: GitlabCI

  1. 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. 2. Click on Create new CI/CD pipeline

    Click on Create new CI/CD pipeline
  3. 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. 4. Grab your MergeBase Customer Token

    Go to the MergeBase dashboard and click on "Settings"

    Grab your MergeBase Customer Token
  5. 5. Find your Customer Token here

    Copy this token for your GitlabCI script

    Find your Customer Token here
  6. 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. 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. 8. Click on Pipelines

    Click on Pipelines

Mergebase

  1. 9. Click on Run pipeline

    Click on Run pipeline
  2. 10. Click on master

    Select the target branch

    Click on master
  3. 11. Click on Run pipeline

    Click on Run pipeline

Gitlab

  1. 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