we have set up Jenkinsjobs with several promotion step which reflect our QS/Testing workflow. In one promotion we trigger a build on an other Jenkins master server. In the log of the promotion build is recorded which buildnumber the job on the remote machine had:
This job is build #[26] on the remote server.
This buildnumber should be available in the next promotionstep in order to set together an URL which points to that buildnumber.
The way I do it now is:
Let both promotions only run on the master
In the second promotion I added an action to execute shell commands:
crlog=${WORKSPACE}/../promotions/03-CREATE_CHANGE_REQUEST/builds/lastSuccessfulBuild/log
crbuildnr=$( grep 'This job is build #\[.*\] on the remote server.' ${crlog} | tr -d [:alpha:][:punct:][:space:])
echo "crbuildnr=${crbuildnr}" > CR-Buildnummer.txt
The file CR-Buildnummer.txt is then used to inject environment variables.
This solution has the drawback that it depends on the masters directory structure.
Is it possible to get the Buildnumber of the remote triggered build without directly reading the log from the filesystem?
I already tried "copy artifact" but I don't know how to name the Project from which the artifact should be copied. I tried ${PROMOTED_JOB_NAME}/promotion/03-CREATE_CHANGE_REQUEST
because this is what the environment variable JOB_NAME was. But i got
ERROR: Unable to find project for artifact copy: TEST_FIT_CQ_Create_FGV/promotion/03-CREATE_CHANGE_REQUEST
This may be due to incorrect project name or permission settings; see help for project name in job configuration.
We are using:
jenkins 1.609.2
promoted build plugin 2.24
copy artifact plugin 1.36