4

I've restricted builds that my Jenkins master executes, since all its slaves are more powerful than it, in Node security settings.

I mean: "Manage Jenkins" -> "Manage nodes" -> master -> "Configure" -> check "Restrict jobs that run on this node" -> "Job restriction" -> "Regular expression". Then enter regexp like ^exact_allowed_job_name$.

Now a pipeline job is stuck in the pending state ("Waiting for next available executor on master").

I cannot find any means to specify a slave that should execute this job in job settings, like the "Restrict where this project can be run" checkbox in freestyle jobs.

Is it possible?

Specifying labels doesn't help. It was the first that I've tried.

This simple pipeline anyway wants the master, regardless 'special' label.

#!/usr/bin/env groovy

node('special') {
   stage('checkout') {
       echo 'checkout'
   }
}

This pipeline is stuck too.

#!/usr/bin/env groovy

pipeline {
    agent none
    stages {
        stage('Checkout'){
            agent {
                label 'special'
            }
            steps {
                echo 'Checkout'
            }
        }
    }
}
wl2776
  • 4,099
  • 4
  • 35
  • 77
  • Does this answer help you ? https://stackoverflow.com/questions/42652533/limiting-jenkins-pipeline-to-running-only-on-specific-nodes?rq=1 – romaric crailox Jan 19 '18 at 15:54
  • No, it doesn't. Specifying labels was first that I've tried. – wl2776 Jan 19 '18 at 15:58
  • 1
    Where do I find these "Node security settings"? Maybe you found a way to block the [flyweight executor](https://stackoverflow.com/questions/44657510/should-i-use-jenkins-heavyweight-or-flyweight-executors-for-notifications) on the master node. Maybe you just need to set the number of executors on the master to 0 instead of using the "node security settings". – Quantic Jan 19 '18 at 18:54

1 Answers1

1

Thanks, @Quantic for pointing to the documentation.

According to it,

every Pipeline build itself runs on the master, using a flyweight executor — an uncounted slot that is assumed to not take any significant computational power.

Since I've set, that job names must match the regexp, which in my case is the exact name of the single allowed job, I've effectively disabled all Pipeline scripts.

Moreover, it is a known bug: https://issues.jenkins-ci.org/browse/JENKINS-31866

The priority of this bug is low, therefore Pipeline plugin is not an option for me.

wl2776
  • 4,099
  • 4
  • 35
  • 77
  • Does setting the number of executors on the master to 0 not work? It should leave the flyweight executors alone. The work to set up and ship jobs to other executors still needs to run on the master as far as I know and since you blocked the master entirely it couldn't even do the flyweight work. The master will look for a place to run the job, see there's "0" executors available on the master, then find an available executor elsewhere, and I think the "Build Executor Status" should show the "master" node doing work when it's really just doing flyweight managing of the jobs. – Quantic Jan 26 '18 at 19:36
  • I haven't checked. This is not an option for me, because my master runs backup job nightly. If I set 0 executors on it, I will disable this job too. – wl2776 Jan 29 '18 at 07:55