From cb7a5b3515785a5d4377104a619c06d8dd01db45 Mon Sep 17 00:00:00 2001 From: andyjk15 Date: Tue, 11 Feb 2020 00:28:59 +0000 Subject: [PATCH] [11.02.20] Basic outline of build pipeline --- configuration/pipelines/build.groovy | 73 +++++++++++++++++++++++++++ configuration/pipelines/deploy.groovy | 2 + configuration/settings.xml | 6 +++ 3 files changed, 81 insertions(+) create mode 100644 configuration/pipelines/build.groovy create mode 100644 configuration/pipelines/deploy.groovy create mode 100644 configuration/settings.xml diff --git a/configuration/pipelines/build.groovy b/configuration/pipelines/build.groovy new file mode 100644 index 0000000..f82c905 --- /dev/null +++ b/configuration/pipelines/build.groovy @@ -0,0 +1,73 @@ +#!/usr/bin/env groovy + +env.APPLICATION_NAME = 'db-gateway' +env.APPLICATION_LABEL = 'gateways' +env.GIT_BRANCH = 'master' +env.GIT_REPOSITORY_PATH = "github.com/andyjk15/${env.APPLICATION_NAME}.git" +env.GIT_REPOSITORY_URL = "https://${env.GIT_REPOSITORY_PATH}" +env.GITHUB_CREDENTIALS_ID = 'cryptosky-admin' +env.DOCKER_REPOSITORY = 'https://registry.cryptosky.me' + +env.NAMESPACE = 'production' +env.SLAVE_LABEL = "cryptosky-aio-build" + +env.CPU_REQUESTS = '1' +env.CPU_LIMIT = '2' +env.RAM_REQUEST = '500MiB' +env.RAM_LIMIT = '1Gi' + +def mvn( String gloals ) { + sh "mvn -s configuration/settings.xml --show-version --batch-mode ${gloals}" +} + +String get_application_version() { + pom = readMavenPom file: 'pom.xml' + "${pom.version}-b${env.BUILD_NUMBER}" +} + +try { + node ("${env.SLAVE_LABEL}") { + stage('Initialise') { + git url: env.GIT_REPOSITORY_URL, branch: env.GIT_BRANCH, credentialsId: env.GITHUB_CREDENTIALS_ID + + env.APPLICATION_VERSION = get_application_version() + + mvn '--version' + } + + stage('Build Artifact') { + mvn 'compile' + } + + stage('Test Artifact') { + try { + mvn 'verify' + } finally { + mvn 'test' + } + } + + stage('Build Image') { + mvn 'clean package -DskipTests' + } + + stage('Deploy') { + + } + + stage('Tag Repository') { + withCredentials( + [usernamePassword( + credentialsId: env.BITBUCKET_CREDENTIALS_ID, + passwordVariable: 'GIT_PASSWORD', + usernameVariable: 'GIT_USERNAME' + )] + ) { + sh "git tag ${env.APPLICATION_VERSION}" + sh "git push https://${GIT_USERNAME}:${GIT_PASSWORD}@${env.GIT_REPOSITORY_PATH} ${env.APPLICATION_VERSION}" + } + } + } +} catch ( exception ) { + throw exception +} \ No newline at end of file diff --git a/configuration/pipelines/deploy.groovy b/configuration/pipelines/deploy.groovy new file mode 100644 index 0000000..8b7c08c --- /dev/null +++ b/configuration/pipelines/deploy.groovy @@ -0,0 +1,2 @@ +#!/usr/bin/env groovy + diff --git a/configuration/settings.xml b/configuration/settings.xml new file mode 100644 index 0000000..6a4f751 --- /dev/null +++ b/configuration/settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file