Re: getting variables from a downstream job

2017-03-07 Thread Thorsten Meinl
Write files with the desired parameters in the "build" job, archive the 
files, and unarchive them in the downstream job. Then you can read the 
parameters stored in the file. Here's a sketch how we do it:

In the upstream job:
def downstreamParams = [:]
downstreamParams.foo = 'bar'
downstreamParams.bar = 'foo'
writeFile file: 'my.params', text: downstreamParams.inspect()
archiveArtifacts artifacts: "*.params"


And in the downstream job:
step([$class: 'CopyArtifact', filter: '*.params', projectName: 
'upstream-project',
  selector: [$class: 'TriggeredBuildSelector', fallbackToLastSuccessful: 
true], target: ''])

def upstreamParams = Eval.me(readFile(file: 'my.params'))



-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/dda635c1-7e0d-485d-8d1d-064d90cf7c37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


getting variables from a downstream job

2017-03-06 Thread Alexander Drobst


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