0% found this document useful (0 votes)
47 views3 pages

Maven CI Pipeline Configuration

pipeline

Uploaded by

misterxnordic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views3 pages

Maven CI Pipeline Configuration

pipeline

Uploaded by

misterxnordic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd

// Automatically generated by occam-ci

/* USAGE:
* Set environment variables to be used by this pipeline in [Link]
* MAVEN_ARGS is added to mvn command, while MAVEN_OPTS add runtime
flags to maven.
* Example
* "build": {
* ...
* "builder": [
* {
* "environment": [
* {
* "id": "maven_opts",
* "name": "MAVEN_OPTS",
* "value": "-Pproxies"
* },
* {
* "id": "maven_args",
* "name": "MAVEN_ARGS",
* "value": "-Xms512m -Xmx1024m -XX:MaxPermSize=1024m"
* }
* ]
* }
* ],
* }
*
*
*/

pipeline {

agent { label 'master' }

stages {

stage('Clone source') {
steps {
git(url: 'ssh://git@[Link]/mb2/mb2-server-
[Link]', branch: 'master', credentialsId: 'openshift-jenkins-ssh')
script {
GIT_COMMIT_ID = sh(
script: 'git --no-pager show -s --format=%h',
returnStdout: true
).trim()
GIT_COMMIT_MESSAGE = sh(
script: 'git --no-pager show -s --format=%B',
returnStdout: true
).trim().replaceAll("[\"|\',]", "").replaceAll("\n+", ". ")
GIT_URL = "ssh://git@[Link]/mb2/mb2-
[Link]";
GIT_REF = "master";
}
}
}
stage('Precondition checks') {
steps {
sh '''
if [ ! -f [Link] ]; then
echo "[Link] not found! Make sure there is a [Link]
file in the root directory in your git repository. Get some inspiration at
[Link] and make a good [Link]!"
exit 1;
fi
'''
}
}

stage('Build Java container image') {


steps {
script {
SA_TOKEN = sh(
script: 'cat /var/run/secrets/[Link]/serviceaccount/token',
returnStdout: true
).trim()
}
sh 'MAVEN_OPTS=""'

sh """#!/bin/bash
mvn clean install -DskipTests=true -P proxies -U jib:build \
-[Link]=unused \
-[Link]="${SA_TOKEN}" \
-[Link]=unused \
-[Link]="${SA_TOKEN}" \
-[Link]="[Link]-
[Link]/base-images/atomic-openjdk-8:latest" \
-[Link]="[Link]-
[Link]/mb-sit/min-bedrift-2-backend:0000” \
-
[Link]="[Link]=Undefined,
[Link]=${GIT_COMMIT_ID}, [Link]=$
{GIT_COMMIT_MESSAGE}, [Link]=${GIT_URL}, [Link]=$
{GIT_REF}" \
-[Link]=true \
-[Link]=/bin/sh,-c,java" "\\\
$JAVA_OPTIONS" "-XX:CICompilerCount=2" "-cp"
"/app/resources:/app/classes:/app/libs/*" "\\\$JAVA_MAINCLASS" "\\\$JAVA_ARGS
"""
}
}
}
}

You might also like