0

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

1 Answers1

0

Assuming you used the correct project, there is an issue within jenkins:

https://issues.jenkins-ci.org/browse/JENKINS-30122

You have to set the permission hudson.model.Item.Read for anonymous user.

OR better read the permission section of the plugin: https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin#CopyArtifactPlugin-Permissionstocopyartifact

Sven
  • 710
  • 9
  • 18
  • Thanks for the Links. I tried the project-based Authorization and the solution to allow the copying of artifacts. Both didn't work.I think the main problem is that the promotions are a kind of Sub-Project inside the Jenkins-Project. But I can't allow the copying of artifacts inside the Promotionstep - so the allowance is only good for artifacts from the outer project. – R. Höllwarth Dec 07 '15 at 11:58