We have a build and deploy process for every artifact(it is not a maven
build, and not a maven arifact). If build or deploy for a single artifact
fails it should not stop the whole process.
We have a separate jobs for build and deploy. Build jobs can work in
parallel on a slaves, deploy not.
The results of a build job should be used by deploy job. I need somehow to
get a workspace location of a build and set it as a parameter of a deploy
job, that deploy job can use ear files from build job and deploy them on a
server.
The place where I need to put a workspace is marked with a question mark.
def branches = [:]
def artifactsToDeploy = []
node{
workspace = pwd()
echo "Workspace:${workspace}"
//read artifact names from file
def appFile=readFile(workspace+"@script/artifacts.txt")
def artifactNames = appFile.tokenize()
//prepare parallel jobs
for (int i=0 ; i < artifactNames.size ; i++) {
def artifactName=artifactNames[i]
branches[artifactName]={
//start build job
def buildResult = build job: 'build-artifact', parameters:
[[$class: 'StringParameterValue', name: 'ARTIFACT', value:artifactName],
[$class: 'StringParameterValue', name: 'SVN_TAG', value:SVN_TAG]]
//need to read workspace from a build job, that was running on a
slave
artifactsToDeploy[artifactsToDeploy.size]=[artifact:artifactName,workspace:?]
}
}
echo 'pipeline begin'
stage('build'){
parallel branches
}
stage('deploy'){
//read artifacts from a list and deploy
for (int i=0;i