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?)
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
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')
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.
Similar like GBEE suggestion (scripts migth be similar):
Using the script consol of jenkins (Manage Jenkins > Script Consol) you can use groovy scripts too.
The script https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/show-labels-overview.groovy creates an ascii table of labels and agents.
Something like this:
|b|d|
|a|c|
| |e|
| |f|
------------------------------------------------------------------------------------------------------------------------
Agent_1 | | |
------------------------------------------------------------------------------------------------------------------------
abcd-agent |X| |
------------------------------------------------------------------------------------------------------------------------
abcd-agent2 | |X|
------------------------------------------------------------------------------------------------------------------------
Related
I have a jenkins job which publishes files to some servers.
I have created a extended choice parameter with server names.
Eg:
Basic Parameter Type -> Paramter Type [Multiselect] -> Values (server1,server2,server3,server) -> delimiter (,).
Which shows correctly on job and I am able to select multiple servers from the choice list.
And I have successfully configured these servers in "Publish over SSH" plugin.
When I select only one server from the list, It works fine,
But when I make multiple selections the job fails and doesn't send any files to selected servers.
Console Output :
20:01:28 SSH: Skipping [server1] - Label [server1] does not match expression [server1,server3]
20:01:28 SSH: Skipping [server2] - Label [server2] does not match expression [server1,server3]
20:01:28 SSH: Skipping [server3] - Label [server3] does not match expression [server1,server3]
Please help on how to select multiple options using the plugin.
The help page says
Parameterized publishing
Publish to servers by matching labels against a regular expression
provided by a parameter or an environment variable.
For each server the label will be matched against the expression, and
if matched, the publish will continue, otherwise that server will be
skipped. If a label is not set for a server it will default to the
empty string. Configured labels have whitespace removed from the start
and end of them, which means that an all whitespace label will be
evaluated as an empty string. The same label can be used multiple
times, e.g. UAT for a database server and again for the web server.
The regular expression syntax is the java syntax.
The labels can use the standard Jenkins environment variables e.g.
$NODE_NAME, or build variables such as a matrix axis.
Parameter name
The name of the parameter or environment variable that will contain
the expression for matching the labels.
This means you have to convert your comma-separated list into a Regular Expression.
You can try to use delimiter | in the Basic Parameter type, that means "or" in RegEx.
Is there a way to use independently the outputs of a checkbox list in the Active Choices plugin on Jenkins ? (as in my example, I need to access to the selected check boxes one at a time
Here are a few screens to explain my problem :
Active Choices configuration in the job
The script
Checkboxes selected
Output
I would like to be able to access first to only the Debian_6, then only the Debian 6 32bits :)
Thanks !
As the result is comma-separated, maybe you could split the output:
# This is a way to split in bash
osArr=(${OS//,/ })
# And then access a result as
os1=${osArr[0]}
Or maybe iterate them in a for block
for os in ${OS//,/ } ; do
echo "${os}"
done
You can store the comma separated values into an array and iterate them
#!/bin/bash
OS_selected=($(echo $OS | tr "," "\n"))
for values in ${OS_selected[#]}
do
echo $values
done
I'd like to create multiple Resources for a certain node, or use a reusable type for several nodes.
In this case it is "RAM requirement", so the resource name e.g. would be 1GBRAM. alternatively 1GBRAM_Nodexy if I need to specify this on a per node basis.
In the end I'd like to limit the amount of concurrent Jobs based on the peak amount of memory a Job uses up on this node, to avoid hangs because of low memory on the server. And I can set the amount of RAM which is available for executors.
Different Nodes will have different amounts of RAM, and individual Jobs have different RAM requirements.
So I would like to configure each Job with its RAM requirements
lock(resource: '1GBRAM_Nodexy', quantity: 8)
Is this achievable with Pipelines and lockable resources?
Is there an alternative, better way to achieve this? Ideally, the locks can be checked before the slave is selected, and the best suited node is picked.
Read about resource locks and labels. I Did not find any Node specific section, also no possibility to acquire multiple items of the same resource.
lock(resource: '1GBRAM_Nodexy', quantity: 8)
I expect that each run of the Job locks the equivalent amount of RAM on the used slave node. If not enough "RAM" units are used up, a Job is not run on such a node.
I think you can't quite do what you're looking for, but perhaps you can come close.
First, what you want is to use label instead of resource. You'd define as many 1GB-representing resources (say, GB1, GB2, GB3, etc.) as you have RAM, giving them all the same label (say, GB), and then use a lock statement like this (e.g., if the job in question needed 4GB of memory):
lock(label: 'GB', quantity: 4)
This will lock 4 of the resources that have this GB label, waiting if needed until it's able to do so, and then will release them when leaving the locked scope.
The node-specific locking is the trickier part. If you were content with using a different label per node (NodeA_GB, NodeB_GB, etc.), and with "pinning" jobs to particular nodes, then the solution above would suffice, e.g.:
// Require 4GB of memory on NodeA
lock(label: 'NodeA_GB', quantity: 4)
What I'm not aware of a way to do is to have a specific node selected because it has RAM available -- i.e., your "the locks can be checked before the slave is selected, and the best suited node is picked" statement. But you could at least detect the node that was allocated by a regular agent statement, using env.NODE_NAME, then use that as part of your node-specific lock label:
agent any
stages {
stage('Build') {
steps {
// This assumes that all possible nodes have a label like this defined with their name in it
lock(label: "${NODE_NAME}_GB", quantity: 4) {
// ... build steps
}
}
}
}
Incidentally, I'm using a label+quantity approach myself but in order to achieve lock-based throttling -- restricting the total number of concurrent builds across all branches of a multibranch pipeline job -- since the Throttle Concurrent Builds plugin went through a period of not being maintained and had some significant, open issues during that time.
Addition to accepted answer(edit queue is full):
As for selecting specific node because it has RAM available -- i.e., your "the locks can be checked before the slave is selected, and the best suited node is picked" statement, a org.jenkins.plugins.lockableresources.LockableResourcesManager class may be used to check available memory on the nodes, and decide, which node to use, for example:
def nodeFreeGbThreshold = 2
def resourceManager = new org.jenkins.plugins.lockableresources.LockableResourcesManager()
def nodeAFreeGb = resourceManager.getFreeResourceAmount("NodeA_GB")
def nodeBFreeGb = resourceManager.getFreeResourceAmount("NodeB_GB")
def agentLabel = nodeAFreeGb < nodeFreeGbThreshold ? 'NodeA' : 'NodeB'
pipeline {
agent { label 'agentLabel' }
stages {
stage('Build') {
steps {
// This assumes that all possible nodes have a label like this defined with their name in it
lock(label: "${NODE_NAME}_GB", quantity: 4) {
// ... build steps
}
}
}
}
}
and for scripted pipelines:
def nodeFreeGbThreshold = 2
def resourceManager = new org.jenkins.plugins.lockableresources.LockableResourcesManager()
def nodeAFreeGb = resourceManager.getFreeResourceAmount("NodeA_GB")
def nodeBFreeGb = resourceManager.getFreeResourceAmount("NodeB_GB")
def agentLabel = nodeAFreeGb < nodeFreeGbThreshold ? 'NodeA' : 'NodeB'
node(agentLabel) {
// This assumes that all possible nodes have a label like this defined with their name in it
lock(label: "${NODE_NAME}_GB", quantity: 4) {
// ... build steps
}
}
I created 2 nodes:
create
(g:gomma:composizione_chimica{tipo:'gomma'}),
(c:composizione_chimica{name:'composizione chimica'})
When I try to visualize in the graph frame the properties instead of ID by clicking the :composizione_chimica label, on the frame bottom there's only the {tipo}property available. So node g hate property "gomma" displayed, node c nothing. How can I fix this?
Unfortunately the web UI doesn't handle multiple labels ideally in situations like this.
If you just do a query for that one node like:
MATCH (c:composizione_chimica) WHERE c.name = 'composizione chimica' RETURN c
Then you should be able to choose the name.
Alternatively if you enter :style in the bar it will bring up a model where you can download a .grass file (a format made for Neo4j), edit it with your change locally, and then upload it again.
Can you plz explain what is your exact problem? As per I understand you have given same label :composizione_chimica to both node. So the node c which have label :composizione_chimica will only show you property {name:'composizione chimica'} and node g which have both label :gomma and :composizione_chimica will show you property {tipo:'gomma'}
Is there a way to search TFS using PowerShell to find all changesets that contain some sub-string in the check-in comment? I'd like to see the individual files in all the changesets in one view. In my case I am searching for all changesets that contain a defect number e.g. 'D-12345'.
I tried the example as outlined here. But running ...
tf history $/MyCodeRepo/Trunk -r /noprompt /format:detailed | ? { $_.comment -like *D-12345* }
... gives me several errors:
You must provide a value expression on the right-hand side of the
'-like' operator.
You must provide a value expression on the
right-hand side of the '*' operator.
Unexpected token 'D-12345*' in
expression or statement.
I then tried putting quotes around the search string but that just returned no results.
I have TFS power tools installed and I know you can use searchcs to search by Comment but you have to open each changeset individually.
Any ideas how I can do this?
Thanks,
Try with
tf history $/ -r | ? { $_.comment -like *D-12345* }
You can also try with fpt searchcs