I am triggering batch file from Jenkins pipeline. In the batch file I have one variable "FailProcessList" whose value i need to return back to Jenkins and store it in a variable in Jenkins pipeline.
For clear understanding below is the flow:-
Jenkins Pipeline --> Trigger --> Batch file --> return "FailedProcessList" to >Jenkins --> Store "FailedProcessList" to a variable in Jenkins.
Below is the way by which I using to exit from the batch and return error code to Jenkins.
if NOT "!FailProcessList!" == "" (
echo failed adapter is !FailProcessList!
echo !error!
if "!error!" neq 0 exit /b !error!
)
What is actually expected is to access and store the variable "FailProcessList" of batch file in Jenkins pipeline variable.
EDIT (After @AndreyG's comment):-
Here is the snippet of how batch file is triggered from Jenkins pipeline.
Jenkins Pipeline deploy stage:-
stage('Deploy') {
steps{
sshagent(credentials: ['84b46545']) {
def codeAndVal = sh(script:"val=ssh user@windowsserver ${params1}deploy.cmd ENV DOMAIN ${params.ADAPTERS} echo ${?},${val}",
returnStdout: true)
}
}
}