I am doing a POC for one of our project and in that i have used GIT and jenkins for CI/CD and it worked perfectly fine for building from one server and then deploying to another server using pipeline job.
Now my question is we have 2 QA and 2PROD instances so how do i deploy to QA first and then later on once business testing and approval is done and then move to PROD.
My system.properties has these values.
Use slash “/” as path separator. Example: Use “C:/SoftwareAG”, instead of “C:\SoftwareAG”.
To achieve the deployment to multiple environments (QA and PROD), you could maybe modify your Jenkins pipeline to include stages for each environment.
You could also use Jenkins input step to pause the job and wait for user input for business approval before deploying to PROD.
First, you would have to add the PROD server settings to your system.properties file.
Then, you could modify your Jenkins pipeline script to include stages for deploying to QA and PROD:
pipeline {
agent any
stages {
stage('Build'){
steps {
bat "${env.SAG_HOME}/common/lib/ant/bin/ant -DSAGHome=${env.SAG_HOME} -DSAG_CI_HOME=${env.SAG_CI_HOME} -DprojectName=${env.JOB_NAME} build"
}
}
stage('Deploy to QA') {
steps {
bat "${env.SAG_HOME}/common/lib/ant/bin/ant -DSAGHome=${env.SAG_HOME} -DSAG_CI_HOME=${env.SAG_CI_HOME} -DprojectName=${env.JOB_NAME} deploy"
}
}
stage('Test') {
steps {
bat "${env.SAG_HOME}/common/lib/ant/bin/ant -DSAGHome=${env.SAG_HOME} -DSAG_CI_HOME=${env.SAG_CI_HOME} -DprojectName=${env.JOB_NAME} test"
junit 'report/'
}
}
stage('Approval') {
steps {
script {
def userInput = input(id: 'confirm', message: 'Approve deployment to PROD?', parameters: [ [$class: 'BooleanParameterDefinition', defaultValue: false, description: '', name: 'Please confirm you agree with this'] ])
if(!userInput) {
error('Deployment to PROD was not approved')
}
}
}
}
stage('Deploy to PROD') {
steps {
bat "${env.SAG_HOME}/common/lib/ant/bin/ant -DSAGHome=${env.SAG_HOME} -DSAG_CI_HOME=${env.SAG_CI_HOME} -DprojectName=${env.JOB_NAME} -DtargetEnv=prod deploy"
}
}
}
}
In the Approval stage, the pipeline should pause and wait for user input. If the user approves, the pipeline would then proceed to the Deploy to PROD stage.
Please note that you would need to modify your Ant scripts to use the correct server settings based on the targetEnv property. If targetEnv is prod, use the PROD server settings; otherwise, use the QA server settings.
Hi Bruno
Thanks for the pipeline code i will try this out. This is my first poc i will check where to add in system properties and where to change the ant build scripts