Jenkins build stalls on `'docker' is waiting` - jenkins

Still waiting to schedule task
‘docker’ is offline
JenkinsFile:
pipeline {
agent {
node {
label 'docker'
customWorkspace "workspace/${JOB_NAME}/${BUILD_NUMBER}"
}
}
...
What is the cause of this error, and how can I diagnose it further?
I don't see any related containers running via docker ps.

Relating to the agent named docker. They can be viewed on the "Build executor status" / "Nodes" / https://jenkins-url.local/computer/

If you use node {} with a specific label, and don't have any nodes with that label set-up, the build will be stuck forever. You also need to make sure you have at least 2 executors set-up when using a single node (like 'master'), otherwise pipeline builds will usually be stuck, as they consist of a root build and several sub-builds for the steps.

Related

Running one particular job in parallel on Jenkins

I have multiple jobs set on Jenkins. There are only one executor on masters, there are many other slaves. I want to create a job which would run on a separate job queue or a separate executor concurrently. How can I achieve this in simplest way? Can it be achieved without modifying slaves?
The next thing is how can I achieve running on any new build for this job in parallel. Rest of the jobs set should not be disturbed and interfered.
As I can understand you need to configure a particular job to run on a slave node...
In order to achieve that you can 1st add a node to the Jenkins master. There you have a place to add a label to that slave node. The in the pipeline script of your job you can edit it as follows.
pipeline {
agent {
node {
label '<YOUR SLAVE NODE LABEL>'
}
}
}
In the latter part of the question, you have asked to run parallel jobs. Please refer to the parallel job documentation If you need to add sequential stages refer to the sequential stage documentation If you want to create a dynamic parallel job this link would help you.

How to schedule Jenkins job when files Check-in with delay

Currently I'm using Serena DIMENSIONS as configuration management with Jenkins for continuous Integration.
Once Developer check in new files in Project folder in Serena, The Jenkins job(which detect changes in Serena DIMENSIONS,download changed files and build the software) needs to be trigger with 15 minutes Delay(Delay is require to complete check in all necessary files.
Can you please tell me the solution?
With Jenkins Pipeline you can create a stage that uses sleep step. For example:
pipeline {
agent none
stages {
stage('Wait') {
agent { label 'wait-node' }
steps {
sleep time: 15, unit: "MINUTES"
}
}
}
}
There's one drawback - your executor is blocked for all the wait time. To work around this in elegant way you can define a dedicated node (wait-node) with large enough number of executors to handle waiting stages (note - other stages may run on different nodes). This way actual executors aren't blocked and you can see all waiting jobs on Jenkins Dashboard.

Jenkinsfile - Build Agents questions

I have following questions about Jenkins build agents:
Question 1: agent any means that "Execute the Pipeline, or stage, on any available agent" - how to check what are list of available agents and what are their capabilities (e.g. one agent can build maven, another not...)?
Question 2: agent { label 'docker' } means that I will use agent called "docker" - how to find out is that agent actually exists? Where to find it?
Thanks for help :)
Jenkins allows you to have multiple agents (nodes or slaves) but when you install jenkins the only agent configured is the master.
It is quite simple to configure new nodes, please refer to one of these guides:
https://wiki.jenkins.io/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines+on+Windows
https://www.packtpub.com/mapt/book/application_development/9781783553471/7/ch07lvl1sec47/managing-jenkins-master-and-slave-nodes
http://www.donaldsimpson.co.uk/2011/10/06/jenkins-slave-nodes/
When you are setting up a new node you can assign labels to it so that you can then use to perform specific tasks on that node from a pipeline, for example.
So answering your questions:
This setting can be done using labels.
Example:
All nodes with maven have a label, eg "maven".
Then running something like agent { label 'maven' } will only execute in one of this nodes.
You can list all available nodes and check the configurations for each one in Manage Jenkins > Manage Nodes.

jenkins & labels getting : pending—master is offline while trying to execute on non-master nodes

I have a Jenkins instance where I am not able to use labels, builds are triggered but get stuck at "pending—master is offline". I have disabled the master (executor # : 0) as I do not wish to use it.
Instead I would expect the build to go to the next available node with the label mentioned in the pipeline.
node("mylabel"){
echo " jenkins pipeline for mylabel nodes"
}
This works in a clean install of jenkins so I can only assume this is a configuration/compatibility issue on my master instance.
Could it be a permission issue?
more info about my master instance :
I have used in the past the nodeLabel (with freestyle jobs) and have removed it (and removed all extra instructions in my jobs once removed via the management view).
I am using the Role-based Authorization Strategy and have defined roles for each projects in jenkins.
Note that I am behind a firewall (no internet access during execution) using Jenkins 2.73.2
EDIT 1:
another syntax - same issue observed.
pipeline {
agent{
label "mylabel"
echo " jenkins pipeline for mylabel node"
}
}
I found the issue occurred because I am not able to bypass the master node using the above pipeline. I understand that before the label selection there is a need for a default node to be available to run instructions.

Jenkins - make agents wait for other agent to finish

I'm new to Jenkins and I'm trying to setup a project which will use few build executors.
The flow shall be as follows:
two build executors with webservice label return their IP addresses and wait for the third build executor to finish its job
third build executor with tester label collects those IP addresses and performs some long running job (e.x. sends HTTP requests to the webservices deployed on those two agents)
How to achieve such behavior in Jenkins?
I've found that when an build executor finishes its job it is immediately released and I don't know how to make it wait for other build executors to finish their jobs.
Edit:
I forgot to mention that I want the build executors with the webservice label to be reserved (not available for other jobs) till the build executor with the tester label will finish its long-running job.
Also all these build executors should be on separate slaves each. That means each slave has only one build executor.
I've finally managed to do this using Pipeline and below script:
node('webservice') {
def firstHostname = getHostname()
node('webservice') {
def secondHostname = getHostname()
node('tester') {
println 'Running tests against ' + firstHostname + ' and ' + secondHostname
// ...
}
}
}
def getHostname() {
sh 'hostname > output'
readFile('output').trim()
}
It acquires two build executors with webservice label. I'm getting their hostnames (I'm using them instead of the IP addresses) and pass them to the build executor with a tester label. Finally the tester runs some long-running tests.
Those two webservice build executors are blocked till the tester finishes its job, and no other project may use them during that time.
As Alex O mentioned, you can configure the master and slave relationship between the projects /executors inside the Jenkins projects /executors. There is option for that, "Build Triggers" -> Build after other projects are built
or use plugin to achieve it
https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin
or
https://wiki.jenkins-ci.org/display/JENKINS/Join+Plugin
What you actually want is probably that your job uses three slaves at the same time.
Re-thinking the setup in that way, it won't be necessary to consider the collection of IPs and the subsequent usage of the slaves as three different steps that must be aligned in some way.
Unfortunately, Jenkins does not support using multiple slaves for one build out-of-the box, but it will be possible to achieve what you want e.g. using the Multijob plugin and the Join plugin that Aaron mentioned already.
See also this question for information on how to use two slaves at the same time.

Resources