Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Fetch artefacts from a triggered build (QB 5.1.33) #3009

Jonathan ·
I want to be able to trigger a build and then, in a post execute action, retrieve some files from the node on which it ran. Alternatively I could retrieve some files from the location where the triggered build published it's artefacts.

Specifically: I have a build that triggers "n" other builds. Each of the triggered builds generates a Jacoco coverage file. I want to be able to fetch the coverage files from each build and merge them to produce an overall coverage report.

I am aware of the transferFiles API, I could potentially use this. However, to use this API I need to be able specify the node on which the triggered build ran, however I see no way to obtain this information. e.g. ConfA runs on Node1, ConfA triggers ConfB which runs on Node3 when ConfB finishes how will ConfA know to retrieve the files from Node3?

I can see that I could pass the agent address where ConfA is running to ConfB (i.e. Node1) and then get ConfB to do the copying, however this unnecessarily complicates ConfB (why should it have to do any copying, as far as it is concerned it has completed its work).

Alternatively I could copy the files from build.getPublishDir(), however now I need to know the build id of the triggered build and I need to be able to create a build object from the build id. Neither of which seem possible.

Any ideas how I can fetch files from a triggered build?

On a more general note it is unfortunate that triggered builds are treated differently to child steps i.e. If I had embedded ConfB within ConfA I would be able to transfer files around using the Fetch Input and Send Output options (I suspect the parent step of "master" is always NULL, it would be nice if the parent step of master could be set dynamically as the step from where it was triggered).
  • replies 6
  • views 3133
  • stars 0
robinshen ADMIN ·
In this case, I'd suggest to go with the dependency approach. That is, for every build generating Jacoco file, first configure it to publish Jacoco files as artifacts via the artifact publish step. Then define a QuickBuild repository in the overall configuration pointing to each build configuration, and set dependency build to be "latest (generate new if necessary)", and define download artifacts to download published Jacoco reports. Finally add checkout step to checkout those QuickBuild repository to checkout those Jacoco reports to workspace of the overall configuration. The trigger build step will no longer be necessary in this case.
Jonathan ·
Using a QB repository seems to work, however...

If the QB repository maps to many configurations how can I check out files with the same name into different folders? i.e.: it would be nice if I could specify a pattern within the destination path field. Please see the below link to see how Apache Ivy handles patterns within its retrieve task:
http://ant.apache.org/ivy/history/lates ... rieve.html
mmckenzie ·
I have a question about this - using "latest build (generate new if necessary)" isn't necessarily what I would want to do with this, as I want to be able to specify a particular version to test against. If it was guaranteed to always generate a new one I could make it work by passing in the version, but my impression is that it will sometimes use a previously run different version.

I've tried the following:
Set the repository build version to "specify a build version"
Added a Trigger step before the Checkout step which triggers the specified build version. (once I get it working I'm planning on adding a condition so it only runs if the version hasn't been found)

However, it seems that the repository check happens before the trigger is run, so this fails.


Is there any way to accomplish what I want here?

Thanks!
robinshen ADMIN ·
By default QB takes snapshot for all repositories before build starts. This is the reason why you see QuickBuild repository determines its version before your trigger build step. To work around this, modify the snapshot taking setting in advanced setting of the configuration to exclude QB repositories like below:
groovy:
for (repo in configuration.getReferencedRepositories()) {
if (!(repo instanceof com.pmease.quickbuild.dependency.QuickBuildRepository))
repo.takeSnapshot();
}

And modify build condition of the configuration as below:
groovy:
for (repo in configuration.getReferencedRepositories()) {
if (!(repo instanceof com.pmease.quickbuild.dependency.QuickBuildRepository) && repo.isChanged())
return true;
}
return false;

To retrieve files to different destination paths, you will have to define different QuickBuild repositories.
mmckenzie ·
Great, thanks! That seems to do the trick.

For anyone else trying this though - there's a very slight typo. QuickBuildRepository should be QuickbuildRepository.

groovy:
for (repo in configuration.getReferencedRepositories()) {
if (!(repo instanceof com.pmease.quickbuild.dependency.QuickbuildRepository))
repo.takeSnapshot();
}
robinshen ADMIN ·
Thanks for pointing this out.