I'm trying to deploy to a node using jenkins, and even though the job recognises the node, when attempting to run the job turns to pending and tries to look through every environment for the node.
I've recently set up a new jenkins job to deploy a spring batch project onto a server. We already have a job for another project to deploy to the same node, so the node is recognised, and when viewing that build it does list three jobs.
However, when trying to run this new job, it attempts to find the node against all of our existing labels (see code below for example output), but doesn't find the actual node it should be running on.
The example I've used is NEW_BATCH_DEPLOYMENT, this is listed with having 3 jobs on the environment, two are new jobs that haven't been run, one is a job that ran just before attempting the batch job and succeeded.
For debugging, we've attempted to deploy with NEW_BATCH_DEPLOYMENT_2, which gives us an error for "can't find node with label NEW_BATCH_DEPLOYMENT_2", and if we remove the node name, it simply runs with one of our default nodes.
Has anyone seen something similar to this, or have any idea of a solution? I've compared the new job against the working job and the only differences are the file paths for where to deploy to, and the git url to pull the projects down.
Jenkins version : 2.181
(pending—; ‘Env_1’ doesn’t have label ‘NEW_BATCH_DEPLOYMENT’; ‘Env_2’ doesn’t have label ‘NEW_BATCH_DEPLOYMENT’; ‘Env_2’ doesn’t have label ‘NEW_BATCH_DEPLOYMENT’;
I'd expect it to deploy to the node, but it just hangs with pending and doesn't reach the stage where it would output to the jenkins console.
As mentioned the other job with similar configuration works.
So just to confirm, that is the exact label you are using? "NEW_BATCH_DEPLOYMENT"? Or is that the name of the node? THe Label should be set in the Node configuration, under the "Labels" section, with no extra characters other than the label name.
I've had issues where it can't find the node label if there are spaces in the label (either on the job side or on the configuration/set-up side)
If the labels are correctly set up, it could also be that the node assigned to "NEW_BATCH_DEPLOYMENT" is offline.
Okay, we fixed it.
It seems that on a node level you can set restrictions on jobs, so when the node was set up, it was restricted to only run the one job. The issue is, the only way you can see this is using an admin login.
If anyone else has this issue I'd highly recommending checking the settings on the node to see if the node itself has any restrictions, rather than the job. You will need a Jenkins Admin to do this.
Related
I'm programmatically updating or modifying some of the node configuration fields. The changes are getting saved in the node but it is not reflecting in the agent config history.
For example, I'm using setNumExecutors() to update the executor count from 1 to 2. Even though the executor field has been updated with a new value, it is not getting reflected in the "BUILD EXECUTOR STATUS" .i.e the Under BUILD EXECUTOR STATUS I can see 1 idle executor whereas it has to be 2.
The above problem gets resolved when we get into the node configuration and save it manually. Through groovy, I can use setNodes() to solve the issue. But setNodes() sets a list of node but I need to update/reflect the configuration change for a single slave. In my R&D, I can conclude that using setNodes() for a single node is a bad idea as it ends up saving that specific node in the master (other nodes gets disappeared)
Please let me know your thoughts on this issue.
Thanks in advance!
The issue resolved when I called the setNode() method through getComputer().
I have a pipeline project with a stage in which a unique identifier is retrieved from an external system and set as the job's display name. I know this identifier to be unique for my whole Jenkins installation, so any search by this key should return exactly zero or one job.
Is there any way I can get a job number/URL (or a list of jobs containing only this one job) given its display name and the project name?
EDIT: I want to find jobs from outside of Jenkins, via user interface or REST API, not from a pipeline.
Take look at Jenkins instance. You can retrieve all Jobs, Folders, ... using the getItem(string)/getItems() methods.
Hardly ideal, but I ended up using the Script Console to list all the jobs, and then used my browsers text search.
Navigate to http://your-jenkins-instance.org.com/script (or Jenkins → Manage Jenkins → Script Console) and run:
Jenkins.instance.getAllItems(AbstractItem.class).each {
println(it.fullName)
};
I have multiple build jobs for a project. ie:
projectA is built with different parameters, for SIT, UAT, Staging and Prod DC1, Prod DC2
I use the build ID within the code for cache busting JS and CSS files.
However, there is a little problem here.
I have multiple build IDs for Prod DC1 and DC2.
for example:
DC1: apple.com/me.js?v=45
DC2: apple.com/me.js?v=78
I need one id to unite them all. so that my apple.js?v=blah wont be different in DC1 and DC2. I am also using CDN so this might become a bigger problem.
How can I do this on jenkins?
If all Jobs are connected as Upstream/Downstream way, create a version label parameter in the first Job and pass this label as parameter to the next downstream job till the last Job.
You can use this as the Unique label from starting Job to last Job.
Use Build Name Setter Plugin to set the build name with the unique label for all the Jobs. So that it will be easy to identify the which build belongs to which label.
To have a full visibility of the Jobs use Delivery Pipeline Plugin
I currently have two jobs that will run around about the same time to one another.
I have two slaves setup, so was hoping that if job #1 starts on slave #1, that when job #2 starts, it would see that slave #1 is busy and use slave #2.
I have installed the NodeLabel Parameter Plugin, set the default node to slave #1, and the possible nodes for slave #1 and #2 for each job. I have set node eligibility to "ignore offline nodes" and "run next build only if job succeeds" (only because I wasn't 100% sure what to select).
The problems I am seeing are:
If slave #1 is in use when the second job starts, it says "(pending—Waiting for next available executor on slave#1) [NodeParameterValue: slave#1=slave#2]" instead of starting on slave #2
When I manually build this job, it doesn't select the default node automatically, instead it makes me choose using "build with parameters"
I am guessing I am missing something rather simple, as I presume this must be a common use for this plugin... to dynamically choose a slave based on which one is not in use?
I solved this by making sure the the job that is getting called has the default and possible nodes both set to the same two slaves. (instead of the default being just #1).
Secondly, the job that calls the slaves must set a variable inside a .properties file which the job defines as to which node should be ran. This variable is then read using the 'all nodes for label factory option' in the calling job.
This article was very helpful, but like I say, I used the 'node for label factory' instead of the 'node label parameter' option he recommends: http://www.shaunabram.com/dynamically-set-jenkins-node/
I'm struggling with something for quite a while and can't find a solution,
I got a test project (cucumber, maven) I configure jenkins to pull the project from github, build and execute the code (selenium test script) on jenkins slave and that works perfect, I added few more slave, tagged them and I'm able to execute the same job parallel(the same test cases on different machines)
my next step is to use grid extra (https://github.com/groupon/Selenium-Grid-Extras) in order to use some cool features like video recording, browser updating, selenium updates etc...
now, I know that in order to use the grid I need to address it via my code and also define the desired capabilities (browser, os etc...).
currently when I'm running the same job twice, my second request will be queued till the first one ends, if I will run the same code from two developers machine it will run at 2 different nodes and the grid can handle both request.
not sure what is wrong with my jenkins configuration or my grid hub configuration, I checked it again and again and all looks good :-)
so guess I'm missing something
any advice/direction/idea will be highly appreciated.
Thanks
Ronen