From f59d99edbf59d33579699f33553da03399402cfe Mon Sep 17 00:00:00 2001 From: gohilamariappan <41056032+gohilamariappan@users.noreply.github.com> Date: Tue, 13 Jul 2021 19:01:17 +0530 Subject: [PATCH 1/2] build.sh added --- build.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..23f9af0 --- /dev/null +++ b/build.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +echo "Docker build script" + +# Build script +set -eo pipefail + +build_tag=$1 +name='workflow-handler-service' +node=$2 +org=$3 + +docker build -f ./Dockerfile --label commitHash=$(git rev-parse --short HEAD) -t ${org}/${name}:${build_tag} . + +echo {\"image_name\" : \"${name}\", \"image_tag\" : \"${build_tag}\", \"node_name\" : \"$node\"} > metadata.json From 1f1894c332eaab653f810bd3db020e48b1daaf7f Mon Sep 17 00:00:00 2001 From: gohilamariappan <41056032+gohilamariappan@users.noreply.github.com> Date: Tue, 13 Jul 2021 19:03:14 +0530 Subject: [PATCH 2/2] Jenkinfile-sun added --- Jenkinsfile-sun | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Jenkinsfile-sun diff --git a/Jenkinsfile-sun b/Jenkinsfile-sun new file mode 100644 index 0000000..885969f --- /dev/null +++ b/Jenkinsfile-sun @@ -0,0 +1,58 @@ +@Library('deploy-conf') _ +node('build-slave') { + try { + String ANSI_GREEN = "\u001B[32m" + String ANSI_NORMAL = "\u001B[0m" + String ANSI_BOLD = "\u001B[1m" + String ANSI_RED = "\u001B[31m" + String ANSI_YELLOW = "\u001B[33m" + + ansiColor('xterm') { + stage('Checkout') { + if (!env.hub_org) { + println(ANSI_BOLD + ANSI_RED + "Uh Oh! Please set a Jenkins environment variable named hub_org with value as registery/sunbidrded" + ANSI_NORMAL) + error 'Please resolve the errors and rerun..' + } else + println(ANSI_BOLD + ANSI_GREEN + "Found environment variable named hub_org with value as: " + hub_org + ANSI_NORMAL) + } + + cleanWs() + checkout scm + commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + build_tag = sh(script: "echo " + params.github_release_tag.split('/')[-1] + "_" + commit_hash + "_" + env.BUILD_NUMBER, returnStdout: true).trim() + echo "build_tag: " + build_tag + + stage('docker-pre-build') { + sh ''' + + docker build -f ./Dockerfile.build -t $docker_pre_build . + docker run --name $docker_pre_build $docker_pre_build:latest && docker cp $docker_pre_build:/opt/target/sb-workflow-handler-1.0.0.jar . + sleep 30 + docker rm -f $docker_pre_buildsb-workflow-handler-1.0.0.jar + docker rmi -f $docker_pre_build + ''' + } + stage('Build') { + env.NODE_ENV = "build" + print "Environment will be : ${env.NODE_ENV}" + sh('chmod 777 build.sh') + sh("bash -x build.sh ${build_tag} ${env.NODE_NAME} ${docker_server}") + } + stage('ArchiveArtifacts') { + archiveArtifacts "metadata.json" + sh ("echo ${build_tag} > build_tag.txt") + archiveArtifacts "build_tag.txt" + currentBuild.description = "${build_tag}" + } + + } + + } + catch (err) { + currentBuild.result = "FAILURE" + throw err + } + finally { + email_notify() + } +}