Reputation: 60193
in Jenkinsfile below, agent docker
is used https://www.jenkins.io/doc/book/pipeline/docker/
But which slave is used, can I point to the VM I want to run docker?
pipeline {
agent {
docker { image 'node:14-alpine' }
}
stages {
stage('Test') {
steps {
sh 'node --version'
}
}
}
}
Something like
agent {
label "dockerserver"
docker { image 'node:14-alpine' }
}
Upvotes: 1
Views: 1051
Reputation: 383
Jenkins assumes any configured agent can run docker containers. This is documented here: https://www.jenkins.io/doc/book/pipeline/docker/#specifying-a-docker-label
A label can be configured in the System Configuration to select which agents can run containers:
Pipeline provides a global option in the Manage Jenkins page, and on the Folder level, for specifying which agents (by Label) to use for running Docker-based Pipelines.
Attach the label to the agents which should run docker containers.
Upvotes: 2