We pulled the change above and rebuilt the plugin but still got 'unable to find job to copy artifact from' errors. We are trying to copy junit test result files from child phases up to the parent job so as to collate build results in one place.
In case someone else is currently blocked by this there is a workaround using the EnvInject plugin. After your build phases have run execute a python build step with the following code. It uses the Jenkins JSON API to create a new file called propsfile containing the build numbers and success/failures of all the child phases that have executed so far as JOB_NAME_BUILD_NUMBER and JOB_NAME_BUILD_SUCCESS (note it replaces hyphens with underscores to avoid invalid environment variables).
#!/usr/bin/env python
import os
import json
import urllib2
url = os.environ['BUILD_URL']
req = urllib2.Request('%s/api/json' % url, headers = {'Accept' : 'application/json'})
res = urllib2.urlopen(req)
res = json.loads(res.read())
f = open('propsfile', 'w')
try:
buildNumbers = {}
for subbuild in res['subBuilds']:
name = subbuild['jobName'].upper()
name = name.replace('-', '_')
f.write('%s_BUILD_NUMBER=%s\n' % (name, subbuild['buildNumber']))
f.write('%s_BUILD_SUCCESS=%d\n' % (name, subbuild['result'].lower() == 'success'))
finally:
f.close()
Then add a subsequent envinject step to pull the contents of that propsfile in and you can use the resulting environment variables to copy artifacts from the correct triggered child builds. You can also use the build success environment variables and the ConditionalJob plugin to optionally run steps (in the case where you have an early smoke test phase that prevents the lengthy subsequent phases from executing if it fails).
Code changed in jenkins
User: itaior
Path:
pom.xml
src/main/java/com/tikal/jenkins/plugins/multijob/MultiJobBuildSelector.java
src/main/resources/com/tikal/jenkins/plugins/multijob/Messages.properties
src/main/resources/com/tikal/jenkins/plugins/multijob/MultiJobBuildSelector/config.jelly
src/main/webapp/help-copyArtifact.html
src/test/java/com/tikal/jenkins/plugins/multijob/test/testutils/FileWriteBuilder.java
http://jenkins-ci.org/commit/tikal-multijob-plugin/9061bb42b52507d3d3624afb6890a3171315c4bc
Log:
Merge pull request #54 from rsennewald/
JENKINS-25111JENKINS-25111Copy Artifacts from Phase JobCompare: https://github.com/jenkinsci/tikal-multijob-plugin/compare/0cd86c543fa3...9061bb42b525