Skip to content

Instantly share code, notes, and snippets.

@dinukadev
Last active November 13, 2019 00:05
Show Gist options
  • Save dinukadev/6dbe6a7adb445a13e2be6836dc0d72ab to your computer and use it in GitHub Desktop.
Save dinukadev/6dbe6a7adb445a13e2be6836dc0d72ab to your computer and use it in GitHub Desktop.
Jenkins build plan pipeline
node {
def mvnHome
env.JAVA_HOME="${tool 'JDK12'}"
env.MAVEN_HOME="${tool 'M3'}"
env.PATH="${env.JAVA_HOME}/bin:${env.MAVEN_HOME}/bin:${env.PATH}"
stage('Checkout source') {
git(
url: "${repo}",
credentialsId: "${GithubCredentialsId}",
branch: "${branch}"
)
mvnHome = tool 'M3'
java_path = tool 'JDK12'
}
stage('Checkout trust-stores') {
dir('trust-stores') {
git(
url: "${infrastructuretruststore}",
credentialsId: "${GithubCredentialsId}",
branch: "master"
)
}
}
stage('Checkout dev-ops') {
dir('dev-ops') {
git(
url: "${devops}",
credentialsId: "${GithubCredentialsId}",
branch: "master"
)
}
}
stage('Checkout dev-ops-dependencies') {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: "${GithubCredentialsId}",
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sh '''
TAG_NAME=`echo "${branch}" | cut -d'/' -f2`
bash dev-ops/dependency-scripts/handle-dependencies.sh $TAG_NAME ${SERVICE_NAME} $USERNAME $PASSWORD
'''
}
}
stage('Build') {
sh "mvn clean package -Dspring.profiles.active=test -Dmaven.test.failure.ignore=false -U"
}
stage('Verify Tests') {
junit 'target/surefire-reports/*.xml'
}
stage('Copy artifacts') {
archiveArtifacts artifacts: "target/${SERVICE_NAME}*.jar", fingerprint: true
}
stage('Invoke deployment') {
build job: "../DeployProjects/${SERVICE_NAME}", wait: false, parameters: [[$class: 'StringParameterValue', name: 'BUILD_NAME_TO_DEPLOY', value: "${env.JOB_NAME}"],[$class: 'StringParameterValue', name: 'BUILD_NUMBER_TO_DEPLOY', value: "${env.BUILD_NUMBER}"], [$class: 'StringParameterValue', name: 'BUILD_BRANCH_NAME', value: "${params.branch}"]]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment