Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View all labels in Jenkins

Tags:

label

jenkins

Is there a easy way to get a list of all node labels in Jenkins?

I can see which labels are set on each node (.../computer/) and which nodes have the same label (.../label/). But similar to listing all nodes on .../computer/ there is no listing of all the labels on .../label/

The approach with python and jenkinsapi or similar seem a bit too advanced for a listing that probably already is available in Jenkins (but not visible?)

like image 239
Daniel Vikström Avatar asked Dec 09 '14 16:12

Daniel Vikström


People also ask

How do I view labels in Jenkins?

I use the Scriptler plugin with the "show labels overview" script that is available from the remote script catalogue. This draws an ascii art table of all nodes versus all labels and makes it easy to see at a glance all the labels that are defined and what nodes use them. Show activity on this post.

What are Jenkins labels?

When creating a new slave node, Jenkins allows us to tag a slave node with a label. Labels represent a way of naming one or more slaves. We leverage this labeling system to tie the execution of a job directly to one or more slave nodes.

How can I see Jenkins nodes?

Click on Manage Jenkins in the left corner on the Jenkins dashboard. Click on Manage Nodes.

What is Agent node label in Jenkins?

The simple answer is, Agent is for declarative pipelines and node is for scripted pipelines. In declarative pipelines the agent directive is used for specifying which agent/slave the job/task is to be executed on.


2 Answers

Haven't installed/tried it myself, but the "label linked jobs" jenkins plugin has a label dashboard as one of its features.. it sounds like this is what you're looking for

like image 116
roomsg Avatar answered Sep 20 '22 10:09

roomsg


Just came across this question. Since I did not want to install a new plugin I tried to achieve the same using the script console.

You even have to possibility to filter-out labels. The following example will filter-out any node name from the list - which is considered a label, too, but probably not relevant to most users:

def allLabels = []  Jenkins.instance.nodes.each { node ->   node.assignedLabels.each { label ->     if (label as String != node.name) {         allLabels += label     }         } }  println allLabels.unique().join('\n') 
like image 20
Joerg S Avatar answered Sep 21 '22 10:09

Joerg S