How to restrict the jenkins pipeline docker agent in specific slave? How to restrict the jenkins pipeline docker agent in specific slave? docker docker

How to restrict the jenkins pipeline docker agent in specific slave?


Just had the same problem, seems to work for me like this:

pipeline {    agent { label 'dockerserver' } // if you don't have other steps, 'any' agent works    stages {        stage('Back-end') {            agent {                docker {                  label 'dockerserver'  // both label and image                  image 'maven:3-alpine'                }            }            steps {                sh 'mvn --version'            }        }        stage('Front-end') {            agent {              docker {                label 'dockerserver'  // both label and image                image 'node:7-alpine'               }            }            steps {                sh 'node --version'            }        }    }}


After read the guideline more, noticed it was stated https://jenkins.io/doc/book/pipeline/docker/#specifying-a-docker-label.

enter image description here

It shall be configured in the jenkins global(system) configuration