You are on page 1of 2

Here is the simple Jenkins declarative pipeline for building ant application on windows machine

running with java version 1.7 . Below pipeline also stages build binary to Jfrog Artifactory .
Since versioning is not supported with java 1.7 in Jfrog, I am copying binary file two different
locations. One is main stage area from where deployment will pick the binary for deployment.
Second one is folder with build date for dev team reference purpose.
pipeline {
agent any
parameters {
choice(name: 'BRANCH', choices: ['<>', 'R1.0','R1.1','R1.2'], description: 'Please select
enviroment')
extendedChoice(description: 'Please select hold area', multiSelectDelimiter: ',', name:
'Hold_Area', quoteValue: false, saveJSONParameterToFile: false, type: 'PT_CHECKBOX',
value: 'QA,DEV', visibleItemCount: 3) }
stages {
stage('Admin Application Build') {
steps {
ws('working directory ')
{
echo "branch NAME ${params.BRANCH}"
cleanWs() // Clean the workspace before build
git branch: "${params.BRANCH}", changelog: false, credentialsId: 'fad47836-fc38-4669-bd22-
6991a7da9693', poll: false, url: 'Git repo url'
echo "branch NAME ${params.BRANCH}"
echo "Updating Buildinfo"
echo "Ant Build "
bat '''cd\\
D:
cd "swicth to ant build.xml folder "
ant -f build.xml'''

}}}
stage ('Coyping files to QA') {
when {
expression { params.Hold_Area == 'QA' }
}
steps {
bat label: '', script: '''
echo off
set CUR_YYYY=%date:~10,4%
set CUR_MM=%date:~4,2%
set CUR_DD=%date:~7,2%
set folder=%CUR_YYYY%%CUR_MM%%CUR_DD%
"C:\\Program Files\\Git\\mingw64\\bin\\curl.exe" -ujfrogusername:password -T "Build Binary
Path\\bin\\sample.ear" https://artifcatory url/repo path//QA/
"C:\\Program Files\\Git\\mingw64\\bin\\curl.exe" -ujfrogusername:password -T "Build Binary
Path\\bin\\sample.ear" https://artifcatory url/repo path//QA/%folder%/'''
}
}
stage ('Coyping files to DEV') {
when {
expression { params.Hold_Area == 'DEV' }
}
steps {
echo "Files copying to hold area DEV!"
bat label: '', script: '''
echo off
set CUR_YYYY=%date:~10,4%
set CUR_MM=%date:~4,2%
set CUR_DD=%date:~7,2%
set folder=%CUR_YYYY%%CUR_MM%%CUR_DD%
"C:\\Program Files\\Git\\mingw64\\bin\\curl.exe" -ujfrogusername:password -T "Build Binary
Path\\bin\\sample.ear" https://artifcatory url/repo path/DEV/
"C:\\Program Files\\Git\\mingw64\\bin\\curl.exe" -ujfrogusername:password -T "Build Binary
Path\\bin\\sample.ear" https://artifcatory url/repo path/DEV/%folder%/'''
}
}
stage('Email') {
steps {
script {
emailext body: "Please migrate sample.ear from path \n https://artifcatory url/repo
path//${params.Hold_Area}", recipientProviders: [requestor()], subject: " ${params.Hold_Area}
Migration for Release $BRANCH - $BUILD_TIMESTAMP ", to: 'E-mail id;E-mail id2'
}
}
}
}
}

You might also like