How to define labels and executor thread count for docker-jnlp-slave?

140 views
Skip to first unread message

Kirill

unread,
Aug 21, 2017, 9:57:07 AM8/21/17
to Jenkins Developers
Hi folks,

I'd like to use docker-jnlp-slave in my docker-compose to spin up slaves for Jenkins master.
However, I didn't find a way to define the labels for the agent - seems that there's no parameter for that. The same for executor thread count.
Furthermore, the Main class of JNLP agent (https://github.com/jenkinsci/remoting/blob/master/src/main/java/hudson/remoting/jnlp/Main.java) doesn't seem to support these parameters as well. However, in agent's details in UI you can define these things.

So is there still a way to define those on container start? Or maybe I should just use an empty busybox-style container calling create-node CLI command (e.g, https://stackoverflow.com/questions/42683324/create-jenkins-jlnp-slave-programmatically/42703928#42703928) to create a JNLP agent?

Carlos Sanchez

unread,
Aug 21, 2017, 9:59:53 AM8/21/17
to Jenkins Developers
that's all defined in jenkins side, not in the agent
you can use the swarm plugin for auto connections

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/b4602caa-73e3-4fc5-b311-b0a9a0f91b26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Oleg Nenashev

unread,
Aug 21, 2017, 1:25:32 PM8/21/17
to Jenkins Developers
+1. Remoting is a communication library, it does not carry Jenkins Node specifics inside.

понедельник, 21 августа 2017 г., 15:59:53 UTC+2 пользователь Carlos Sanchez написал:
that's all defined in jenkins side, not in the agent
you can use the swarm plugin for auto connections
On Mon, Aug 21, 2017 at 3:57 PM, Kirill <yam...@gmail.com> wrote:
Hi folks,

I'd like to use docker-jnlp-slave in my docker-compose to spin up slaves for Jenkins master.
However, I didn't find a way to define the labels for the agent - seems that there's no parameter for that. The same for executor thread count.
Furthermore, the Main class of JNLP agent (https://github.com/jenkinsci/remoting/blob/master/src/main/java/hudson/remoting/jnlp/Main.java) doesn't seem to support these parameters as well. However, in agent's details in UI you can define these things.

So is there still a way to define those on container start? Or maybe I should just use an empty busybox-style container calling create-node CLI command (e.g, https://stackoverflow.com/questions/42683324/create-jenkins-jlnp-slave-programmatically/42703928#42703928) to create a JNLP agent?

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.

Kirill

unread,
Aug 22, 2017, 11:13:04 AM8/22/17
to Jenkins Developers
Thanks for your comments, guys, I have found a solution that combines the creation of slave and an agent launch.

Just in case someone needs it.

1. Have an XML jnlp_slave.xml with slave description containing executor thread count and labels, e.g.

<slave>
  <remoteFS>/opt/jenkins2</remoteFS>
  <numExecutors>2</numExecutors>
  <launcher class="hudson.slaves.JNLPLauncher" />
  <label>fat</label>
</slave>

2. Run the following script to start agent (considering that http://jenkins:8080/jenkins/ is a Jenkins main page):

wget http://jenkins:8080/jenkins/jnlpJars/jenkins-cli.jar
cat jnlp_slave.xml | java -jar jenkins-cli.jar -s http://jenkins:8080/jenkins/ create-node my-agent
slaveComputerMac=`echo 'println jenkins.model.Jenkins.instance.nodesObject.getNode("my-agent")?.computer?.jnlpMac' | java -jar jenkins-cli.jar -s http://jenkins:8080/jenkins/ groovy =`
docker run jenkinsci/jnlp-slave -url http://jenkins:8080/jenkins/ ${slaveComputerMac} my-agent

Regards,
K.

понедельник, 21 августа 2017 г., 14:57:07 UTC+1 пользователь Kirill написал:
Reply all
Reply to author
Forward
0 new messages