NodeLabel Parameter Plugin not working with pipelines - jenkins

My current setup is not working well with the NodeLabel Parameter Plugin and I am wondering if I am missing something, I find the documentation at https://wiki.jenkins.io/display/JENKINS/NodeLabel+Parameter+Plugin incomplete (e.g. it is missing any info on node configuration when using label restriction).
My setup :
- nodes are setup with the options : 1) only build job with label expressions matching this node 2) label field set to 'mytest'
- pipeline definition in jenkins gui set with the following option checked 'This project is parameterized', I have added the label default value to 'mytest'. I kept the default name to 'executor label' based on the documentation (guessing this is not relevant though)
Result : the job gets stuck, output below
[Pipeline] node [...all my agents listed here] is reserved for jobs with matching label
I am using a shared library for my pipeline, I also have tried to add the label in the node object :
node{ label 'mytest' }
same issue. I m not finding much help online - again I am surprised by the lack of details in the Jenkins plugin documentation.
Any suggestion? thanks

Related

Jenkins Addon in Jenkins Pipeline

I have a parameterized project. With the variable VAR1.
I'm using the the Xray for JIRA Jenkins Plugin for Jenkins. There you can fill four parameters:
JIRA Instance
Issues
Filter
File Path
I'm new to Jenkins but what I have learned so far, that you can't fill this fields with environment variables. Something like
Issues: ${VAR1} - doesn't work.
So I thought I can do this with a pipeline. When I click on Pipeline Syntax and chose step: General Build Step I can choose Xray: Cucumber Features Export Task. Then I fill the fields with my environment variable and click Generate Pipeline Script The output is as follows:
step <object of type com.xpandit.plugins.xrayjenkins.task.XrayExportBuilder>
That doesn't work. What I'm doing wrong?
All you're doing is OK, but what you want is not supported by Jenkins whether it is pipeline or not, since the parameters' load is happening prior to the pipeline-flow or the definition of the ${VAR1}.
You can try to overcome this by defining the 'Issues' value as a pipeline internal value instead of a parameter and base it on the ${VAR1} value.
If it must be a parameter, use 2 jobs where one defines the value of 'Issues' based on a the ${VAR1} and pass it to the other job that gets the 'Issues' as a fixed value.

Customize Jenkins pipeline stage view

How can i add the little blue tags to stage view in a Jenkins Pipeline?
I was searching for this as well and found the following after reading Hatim's answer:
The line that was supposed to show the node label is commented out:
source
The referenced issue JENKINS-33290 is Resolved with the last comment:
Resolved by removing the functionality, since a correct implementation imposes unacceptable complexity and overhead.
So I'm afraid it's not coming back soon and all those screenshots online are outdated.
Is the name or label of the node used.
Please refer to this
https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/
node: Allocate node
Allocates an executor on a node (typically a slave) and runs further code in the context of a workspace on that slave.
label
Computer name, label name, or any other label expression like linux && 64bit to restrict where this step builds. May be left blank, in which case any available executor is taken.
In this case, the stage is executed in the master, if you configure your jenkins pipeline to be executed in differents plateforms (master-slaves), then you will be able to see the label of your slaves environement.

How can I select some projects to be eligible to be built by slaves

I've created successfully my 1st Jenkins slave, but I don't want to be used to all the projects, so I've chosen the {{Only selected projects}} option.
But how can I choose the projects?
I've looked at Jenkins management, and the configuration of a project, and I don't see the needed setting.
You tie jobs to slaves in the jobs' configuration: go to ${jenkins url}/job/${job name}/configure and look for the Restrict where this project can be run field in the general settings:
You can type names of slaves there, or even better, use tags assigned to slaves. You can use logical expressions like || and &&, too.
To expand on ameba's answer you can set labels for a node in the node configuration settings and therefore label nodes with the toolchains or tools that you require.
Then in jenkins-pipeline you can do the following:
node('TOOL label')
{
stage('build using TOOL') {
}
}
the node section tell jenkins to find a node with that label and to use it for the following block of code.

How to select a node name as a parameter in jenkins using a selection list of some sort

I need to know if there is a plugin of some sort that you can select a node from a jenkins job and use that node name as a parameter to be passed to a Windows batch command
I have played with the Configuration Matrix using an Elastic-Axis or Slaves (Screenshot below where you can tick the names) plugins
But these all go and execute the Windows batch command on that selected node.
I don't want to execute it on that server but rather on the main node and only pass the value of the slave/label to the windows batch command.
I were able to do it as described here but that involves 2 jobs and a groovy scripts to interrogate the slaves/nodes config. Write it to a properties file and pass the properties file to the next job.
Jenkins: How to get node name from label to use as a parameter
I need to do about 30 jobs of these and hence would like to try to do all in one job - if I used my solution in the link above, 30 jobs would double in 60 jobs and maintenance would be kind of a nightmare.
I also would not like to have a string parameter and hard code the name of the slave/node as that will not ensure the use of only the available slaves/nodes but any server name can be entered and that would can be a problem where someone can mistype a server name for example pointing to a Production server instead of a test server.
https://wiki.jenkins-ci.org/display/JENKINS/NodeLabel+Parameter+Plugin
After installing this plugin you will have an option to add a Node parameter to Jenkins job. It will have a list of all slaves available on current master.
You can use the active choice parameter plugin
https://plugins.jenkins.io/uno-choice/
with a little groovy script to list node names in a parameter selection box.

Jenkins Label parameter Issue

I created 4 slaves in my Jenkins and give a same label "test".Now I want when I will give the test label the deployment should run on all the slaves which is having the label test but unfortunately it is not working.while I give the test label it shows all the nodes which is associated with them but it doesn't execute the job on all slaves just only one.
The first picture shows how I am defining the Label parameter in the jenkins job.it shows Run on all nodes matching the label
The second pic shows while I am giving test in deployeLayer it shows all the nodes but after executing it this doesn't run the job on all matching nodes.
Can someone tell me if I am missing something
I am using the below version
Jenkins ver. 1.558
Node and Label parameter plugin = 1.5.1
See NodeLabel Parameter Plugin, BuildParameterFactory:
The nodelabel parameter plugin also adds a BuildParameterFactory to the parameterized trigger plugin, this factory enables you to trigger a build of a specific project on all nodes having the same label.

Resources