Oscar van der Meer
Created Feb 23, 2022How to Use MergeBase in: GitlabCI
231
#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"
Make any other changes to your pipeline as necessary. See https://docs.gitlab.com/ee/ci/ for full Gitlab Documentation.
Well done!
Create how-to guides like this in a snap. Get Tango now.