Get final result Multijob from several hosts (Jenkins) - jenkins

I have a MultiJob Project with structure:
Master MultiJob Project (Job)
|----- Phase 1
|------> JOB A
|------> JOB D
|----- Phase 2
|------> JOB B
|------> JOB D
|----- Phase 2
|------> JOB C
Main Job (Master MultiJob Project) run on the Master, but other jobs can run on another free worker, but result of each Job(A/B/C/D) must send to Master MultiJob to collect result and get summury result of all jobs.
When all Jobs was on one host I use:
ln -s $WORKSPACE/$REPORTSDIR
where $WORKSPACE I send from Master MultiJob like a parameter, but if they on differents hosts I cann't use this solution. What is the best way to solve this problem?

Wait for sub-jobs to complete. They must keep the reports as artifacts.
From master job get sub-jobs build numbers and copy artifacts from finished sub-jobs.
This is in general what you have to do. But you must be more clear what type of build are you using - pipeline or simple freestyle project? You might need to install Copy Artifact Plugin.

Related

How to trigger a Jenkins Pipeline job to use the same workspace

I have 2 pipeline jobs. JOB A & JOB B
I want to trigger JOB B to run on the same node and workspace of JOB A.
When I do so, Jenkins adds "#2" to the workspace of JOB B. for example:
JOB A workspace = /DATA/Jenkins_User/workspace/JOB-A
JOB B receives the correct workspace as parameter,
but when I perform ws(customWorkspace) it is being built in
/DATA/Jenkins_User/workspace/JOB-A#2
Any idea how can I remove the "#2" characters?

Use and copy artifacts within one job in multiple subjobs/nodes - Jenkins

Hello,
We're using one job (B) which calls another job (C) 3-times with different parameters within one job (B). Every job-C run is used for different slaves/nodes, with different parameters.
Job B is using some artifacts from job A and all the sub-jobs (C) should even uses these artifacts. Unfortunately only the first triggered sub-job (Job C #1) becomes the artifacts provided within his local workspace folder. For the other Job-C runs (#2 and #3) the artifacts will not be copied.
Schema:
Job A (creates the artifacts)
-->Job B (uses artifacts from A and triggers Job C, three times)
--> Job C #1 --> use artifacts for node1
--> Job C #2 --> should also use the artifacts on node2 (didnt work)
--> Job C #2 --> should also use the artifacts on node3 (didnt work)
One solution could be configure a group for all job-c nodes and to use "execute on all nodes in label" in the trigger. But we need to call Job-C with different parameters.
Thanks Steffen
Here is a solution with the Build Flow plugin, the NodeLabel parameter plugin and the Copy Artifact plugin.
With this solution, no need of the job B.
The job A creates the artifacts, no need to update this job.
On the job C, please this kind of parameter (using the second plugin):
Please active this option for your job C:
Add a build step to copy the artefact from the job A:
Next, create a new build flow job with this flow:
build("Bruno job A")
parallel (
{ build("Bruno job C", NODE_NAME: "jenkins-centos-slave-01") },
{ build("Bruno job C", NODE_NAME: "jenkins-centos-slave-02") },
{ build("Bruno job C", NODE_NAME: "jenkins-centos-slave-03") }
)
The parallel block will launch 3 times the job C on 3 different slaves.
We can check that the 3 jobs C have been executed on the relevant nodes:
And they all get the artefact from the job A :)

Triggering a Hudson job when all upstream jobs are completed?

I have 3 jobs A,B,C. Job C has upstream Dependency on Job A and Job B. Both Job A and B can run in pararllel. We want that the Job C should only be triggered when Job A and Job B are completed. Is there any existing plug-in that I can use? We are using Hudson 3.0.1
From other posts here I figured out that there is an existing plug-in in Jenkins called Build-Flow Plug-in(https://wiki.jenkins-ci.org/display/JENKINS/Build+Flow+Plugin) that provides this functionality. Is there some plug-in existing in Hudson that provides same functionality ? Or can I reuse this plug-in for Hudson ?
Try Build Pipeline Plugin,this may do what you want.
Try Multijob Plugin
(https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin)
It provides Multiphase configuration.
If you want to run 2 or more jobs in parallel then put all the jobs in same phase.
In your case you need to create 2 phases
Example:
phase 1:
job A
job B
phase 2:
job C
here phase 2 executes only after the completion of phase 1.

Jenkins MultiJob - Send Results e-mail with data from inner Jobs

I have a MultiJob Project with 3 inner jobs which needs to be executed in the following sequence
Master MultiJob Project (Job)
|----- Phase 1
|------> JOB A
|----- Phase 2
|------> JOB B
|----- Phase 2
|------> JOB C
When Job C ends, the Master MultiJob Project (Job) will send a mail (Using the Email-ext plugin) with status about the results from all the inner Jobs (A, B and C) (As a Post Build Step)
I need to find a way to get a the results from each of these inner Jobs (as Parameter or any other way...)
I tried to do it by:
Setting Enviroment Variable and then trying to read it - Failed - the Varaiable is not exisintg anymore after Job A/B/C ends
Tried to do so with SETX, same results
Tried to use the EnvInject Plugin and failed again
isn't there anyway to do so?
Can someone shade some light?
Assuming your job is a Multijob, you can add a groovy post build like this:
subBuilds = manager.build.getSubBuilds()
//print the each sub build instance to the console log and its result
subBuilds.each{
manager.listener.logger.println "${it}, ${it.getResult()}"
}

Jenkins Parallel Trigger and Wait

I have 4 jobs which needs to be executed in the following sequence
JOB A
|------> JOB B
|------> JOB C
|------> JOB D
In the above
A should trigger B & C parallely and C inturn triggers D.
A should hold the job as running till all 3 of them completed.
I tried the following plugins and couldn't achieve what I am looking for
Join Plugin
Multijob Plugin
Multi-Configuration Project
Paramterized Trigger Plugin
Is there any plugin which I haven't tried would help me in resolving this. Or is this can be achieved in a different way. Please advise.
Use DSL Script with Build Flow plugin.
try this Example for your execution:
build("job A")
parallel
(
{build("job B")}
{build("job C")}
)
build("job D")
Try the Locks and Latches plugin.
This may not be optimal way, but it should work. Use the Parameterized Trigger Plugin. To Job A, add a build step (NOT a Post Build Action) to start both Jobs B and C in the same build step AND block until they finish. In Job C, add a build step (NOT a Post Build Action) that starts Job D AND blocks until it is finished. That should keep Job A running for the full duration.
This isn't really optimal though: Job A is held open waiting for B and C to finish. Then C is held open until D is finished.
Is there some reason that Job A needs to remain running for the duration? Another possibility is to have Job A terminate after B and C are started, but have a Promotion on Job A that will execute your final actions after jobs B, C and D are successful.
I am trying to build a same system. I am building a certification pipeline where I need to run packager/build/deploy jobs and and corresponding test jobs. When all of them are successful, I want to aggregate the test results and trigger the release job that can do an automated maven release.
I selected Build pipeline plugin for visualization of the system. Initially tried with Parameterized trigger Plugin with blocking builds. I could not setup archiving the artifacts/fingerprinting and downstream build relationship this way since archiving the artifacts works only in postbuild. Then I put the Parameterized trigger in Post build activity. This way I was able to setup downstream builds, fingerprinting, aggregate test results but the build failures were not bubbling to upstream job chain and upstream jobs were non blocking
I was finally able to achieve this using these plugins-
Build Pipeline
MultiJob Plugin
FingerPrint Plugin
Copy Artifacts Plugin
Join Plugin
I'm using Jenkins 1.514
System looks like this
Trigger Job --> build (and deploy) Job (1..n) ---> Test Job (1..n)
Trigger Job -
Create as MultiJob and create a fingerprint file in shell exec
echo date +%s > fingerprint.txt
Trick is that file needs to be archived during the build, to do that execute this script-
ARCHIVEDIR=$JENKINS_HOME/jobs/$JOB_NAME/builds/$BUILD_ID/archive
mkdir $ARCHIVEDIR
cp fingerprint.txt $ARCHIVEDIR
Create MultiJob Phase consisting of build/deploy job.
Build/deploy job is itself a multijob
follow the same steps for creating build/deploy job as above relative
to fingerprinting.
Copy the fingerprint.txt artifact from upstream job
Setup MultiJob phase in deploy job that triggers the test job
create a new fingerprint file and force archive it similar to above step
Collect Junit results in the final test job.
In the trigger Job, use Join Plugin to execute the Release Job by choosing 'Run Post Build Actions at join' and execute the release project only on stable build of Trigger Job.
This way all the steps are showing up in Build Pipeline view and Trigger job is blocking for all downstream builds to finish and sets its status as the worst downstream build to give a decision point for release job.
Multijob Plugin
If you'd like to stop the mess with downstream / upstream jobs chains definitions. Or when you want to add a full hierarchy of Jenkins jobs that will be executed in sequence or in parallel. Add context to your buildflow implementing parameter inheritance from the MultiJob to all its Phases and Jobs. Phases are sequential while jobs inside each Phase are parallel.
https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin

Resources