Pipeline
Pipeline
Pipeline
/* USAGE:
* Set environment variables to be used by this pipeline in spec.json
* 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 {
stages {
stage('Clone source') {
steps {
git(url: 'ssh://git@prima.corp.telenor.no:7999/mb2/mb2-server-
side.git', 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@prima.corp.telenor.no:7999/mb2/mb2-
server-side.git";
GIT_REF = "master";
}
}
}
stage('Precondition checks') {
steps {
sh '''
if [ ! -f README.md ]; then
echo "README.md not found! Make sure there is a README.md
file in the root directory in your git repository. Get some inspiration at
https://www.makeareadme.com, and make a good README.md!"
exit 1;
fi
'''
}
}
sh """#!/bin/bash
mvn clean install -DskipTests=true -P proxies -U jib:build \
-Djib.from.auth.username=unused \
-Djib.from.auth.password="${SA_TOKEN}" \
-Djib.to.auth.username=unused \
-Djib.to.auth.password="${SA_TOKEN}" \
-Djib.from.image="docker-registry-default.test-
dc.corp.telenor.no/base-images/atomic-openjdk-8:latest" \
-Djib.to.image="docker-registry-default.test-
dc.corp.telenor.no/mb-sit/min-bedrift-2-backend:0000” \
-
Djib.container.labels="no.telenor.system.number=Undefined,
no.telenor.git.commit.id=${GIT_COMMIT_ID}, no.telenor.git.commit.message=$
{GIT_COMMIT_MESSAGE}, no.telenor.git.url=${GIT_URL}, no.telenor.git.ref=$
{GIT_REF}" \
-Djib.useCurrentTimestamp=true \
-Djib.container.entrypoint=/bin/sh,-c,java" "\\\
$JAVA_OPTIONS" "-XX:CICompilerCount=2" "-cp"
"/app/resources:/app/classes:/app/libs/*" "\\\$JAVA_MAINCLASS" "\\\$JAVA_ARGS
"""
}
}
}
}