How to deploy webMethods packages to multiple environments with one pipeline job

Hi All

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”.

deployerInstallationPath=${SAGHome}/IntegrationServer/instances/abhijith/packages/WmDeployer/bin/

#Build Server Settings
deployerHost=localhost
deployerPort=5555
deployerUsername=*****
deployerPassword=*****

#Target CI Test Server Settings
testISHost=localhost
testISPort=7777
testISUsername=*****
testISPassword=*****

and my pipeline stages are these

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') {
        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/'
        }
    }
}

}

i tried to add one more server in system.properties but that didnt work so how to achieve this. Thanks in advance.

Hello @abhijithwebmethods and welcome to this community. :wave:

To achieve the deployment to multiple environments (QA and PROD), you could maybe modify your Jenkins pipeline to include stages for each environment. :thinking:
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

Regards
Abhiijith

Hi @abhijithwebmethods,
We’re also looking for an answer for the same issue
Did you find a solution for it?

Thanks