Reputation: 358
I'm currently new to Jenkins and there is a situation, where I would like to create a set of Jenkins jobs with the following flow:
A -> B -> C
To give you context, I have Job A (Which is designed as an initialiser to grab the results of Jobs B and C together in 1 artifact), Job B (takes the results of Job C, CSS and JS files and builds them into a war file, with other required files) and Job C (which builds minified CSS and JS files for a particular customer. Each build will pass in different customers as a parameter)
Normally I would be able to use the Parametrized Trigger, Copy Artifact and Build Name Setter I could Run Job A which triggers Job B and in turn Triggers Job C which the output of Jobs B and C would be the output of the subsequent upstream job. So theoretically in the end in Job A I would receive the output of Job B.
I have tried inserting ${TRIGGERED_BUILD_NUMBER_JOB_C} in build A when we are copying artifact for Job C under 'Specific Build' of the copy artifact plugin, however, the error that I get is:
Copied 1 artifact from "JOB_B" build number 15 ERROR: Unable to find a build for artifact copy from: JOB_C
I've seen other settings under the copy artifact plugin such as "Downstream build of" or "Upstream is a trigger of" but I'm not sure on the specifics in what they do or whether or not these are the settings that will achieve what I need.
Furthermore, I could've done 'Last Successful Build' on Job C, however, I fear that if there are multiple people running job C at close to the same time, they would end up getting the wrong build as each CSS and JS build can be for a different customer.
So rather than continue and knocking my head, I was wondering this is possible and what would be the steps I need to get this flow?
Thanks.
Upvotes: 2
Views: 546
Reputation: 2481
From what I'm gathering, Job A should be last in the flow since its job is to take the artifacts from both B and C and publish them? Even if it did do something like setup/initialization, perhaps you could split job A into 2 jobs (one for initialization and another for publishing). Maybe something like:
Job D (Initialization) -> Job B -> Job C -> Job A (Publish)
This will make it more linear rather than having to do a join at the end.
In regards to your question about getting the artifacts from Job B and Job C, you could perhaps write a dsl using the Build Flow Plugin. You can then pass in the build number's of job B and Job C into Job A and copy them into the workspace using the Copy Artifacts Plugin.
For example, something like:
jobB = build( "jobB" )
jobC = build( "jobC" )
build( "jobA", param1: jobB.build.number, param2: jobC.build.number )
Upvotes: 0