def hosts=[]
def TARGETLEVEL="L2"
def UC_CM_ID="CM"monospaced text
script
{
START_SERVER_LIST2.each
{
CURRENT_END_HOST="${it}".trim()
END_SHORT_HOST="${CURRENT_END_HOST}".substring(0,"${CURRENT_END_HOST}".indexOf("."))
CREDENTIAL_ID="$TARGETLEVEL""""$UC_CM_ID""""${END_SHORT_HOST}"
hosts.add("${CREDENTIAL_ID}")
}
def servers = START_SERVER_LIST2
def projectsBuilds = [:]
for (int j=0; j<=5;j++)
{
def currentServer = START_SERVER_LIST2.get(j)
projectsBuilds[currentServer] = {
stage(String.format('%s execution', 'Checkout on'+currentServer))
{
def TAGNAME="TEST"
def SOURCE_BRANCH_NAME="main"
def TARGET_BRANCH_NAME="main"
def SAVE_FILE_PATH="/tmp"
def UTILITY_SCRIPT_DIR="/tmp"
def level_name="L2"
def user_name="cm"
CURRENT_END_SERVER="${currentServer}".trim()
END_SHORT_HOSTNAME="${CURRENT_END_SERVER}".substring(0,"${CURRENT_END_SERVER}".indexOf("."))
END_CM_USER_CREDENTIAL_ID="$TARGETLEVEL""""$UC_CM_ID""""${END_SHORT_HOSTNAME}"
echo "END_CM_USER_CREDENTIAL_ID=$END_CM_USER_CREDENTIAL_ID"
sshagent(credentials: ["${END_CM_USER_CREDENTIAL_ID}""])
}
}
}
echo "Parallel builds"
print(projectsBuilds)
parallel projectsBuilds;
}
we are creating stages dynamically based on the START_SERVER_LIST2 parameter. Created stages running parallelly except sshagent block. When sshagent starts its execution parallely it runs for only last server of START_SERVER_LIST2 parameter.
Is sshagent blocks paralllel mechanism?
how to run sshagent parallely for different servers?
how to pass different parameter values for sshagent block?
What happens if you add 'def' before the END_CM_USER_CREDENTIAL_ID variable?