4

On our Jenkins master a Multi-configuration project is used to spread a highly parallel task on many slaves which actually do the work.

Now I would like to list all jobs, which were running on a specific slave node. Is there a way to achieve this? I see only all matrix sub jobs for one matrix parent job in a big table. Or I can list the history of a single sub job. But if I want to get the connection to the node, where the job was running on, I always have to check the logs.

Vitalii Elenhaupt
  • 6,666
  • 3
  • 23
  • 39
Flow Rei Ser
  • 111
  • 1
  • 2
  • 7
  • In terms of multi-configuration project, those "sub-jobs" are called "configurations". Could you please show us config of your axis in "Configuration Matrix" section (job configuration)? – Vitalii Elenhaupt Jun 17 '15 at 05:48
  • Hi Vitalii, thank you for your comment. I'm not quite sure, why you need this information, because I'm just searching for a plugin, which lists the job history by a different point of view (sorted by nodes). But our configuration has one "Slaves" axis, which actually ensures, that the "matrix-configurations" (in my terms "sub-jobs" ;-)) are spread to slaves marked with a given label. In addition, we have five "User-defined" axes to vary our device configuration. – Flow Rei Ser Jun 17 '15 at 06:54

3 Answers3

3

You can use Description Setter Plugin like the following:

enter image description here

Then you will have node label in the description of each build:

enter image description here

Vitalii Elenhaupt
  • 6,666
  • 3
  • 23
  • 39
2

Now I would like to list all jobs, which were running on a specific slave node.

I didn't find any existed plugin to solve the problem. But you can automate it a bit with a Jenkins Script Console. Here is a simple groovy script that iterates through job's builds and checks whether that build was built on a concrete node:

def jobs = hudson.model.Hudson.instance.items

nodeName = 'YOUR_NODE_NAME'

jobs.each { job ->
  urls = []
  job.builds.each { build ->
    nodeName == build.builtOnStr && urls << build.absoluteUrl
  }
  urls && println("${job.name}\n\t${urls.sort().join('\n\t')}")
}

Sample output:

JOB1    
    JENKINS_URL/job/JOB1/11/
JOB2
    JENKINS_URL/job/JOB2/59/
    JENKINS_URL/job/JOB2/60/
    JENKINS_URL/job/JOB2/61/
    ...

If you would like to go further, you could use it to prepare some clickable html report. First that comes to the mind is to send emails with Email-ext plugin.

Note: that script will not work with nodeName = 'master'. This should be expected 'cause master, actually, is not a node.

Vitalii Elenhaupt
  • 6,666
  • 3
  • 23
  • 39
  • Hi Vitalii, thank you for your help. I will use your solution, if I can not find any other way. It is definitively better than to check all the logs manually :-) – Flow Rei Ser Jun 18 '15 at 10:16
  • @Vitalii Elenhaupt, is there a way to list projects (not jobs have been run) currently restricted to a particular node? We want to get ride of some nodes, want to notify projects using these nodes. – Jirong Hu Jul 15 '16 at 20:50
1

I've solved it like this using the script console

for (item in hudson.model.Hudson.getInstance().getItems()) {
  if (item instanceof hudson.model.FreeStyleProject) {
    if (item.getAssignedLabel() != null && item.getAssignedLabel().getName() == 'master') {
      println(item.getName() + " " + item.getAssignedLabel())
    }
  }
}
OhadBasan
  • 737
  • 5
  • 13
  • This seems to answer "which node the job is assigned to", and does not work with pipeline jobs where node is assigned during run time. – sterdun Feb 24 '20 at 18:52