jenkinsci / docker-swarm-plugin

Jenkins plugin which allows to add a Docker Swarm as a cloud agent provider
https://plugins.jenkins.io/docker-swarm/
MIT License
55 stars 47 forks source link

Placement constraint whitelists #87

Open jkao97 opened 4 years ago

jkao97 commented 4 years ago

Documentation states we can specify placement with, for example, node.role!=manager;node.hostname!=node-2. Is there a way to whitelist instead of blacklist where jobs can be assigned to?

Something like node.hostname==node-2 works but I'm looking for a way to enable on multiple nodes. I've tried something like node.hostname==node-2;node.hostname==node-3, but this doesn't seem to work (job just gets stuck in queue).

gutschet commented 4 years ago

You can add labels to the hosts you want to use::

docker node update --label-add <label-name>=<label-value> <node>

for example:

docker node update --label-add whitelisted=yes node-1

Then you can use the label for the placement constrinat like this:

node.labels.<label-name>==<label-value>

for example:

node.labels.whitelisted==yes