Hi
I want to be able to use a pipeline, and as my first step specify a docker image and then have the rest of the job run in a container spun up based on that image. Ideally I would like to use this on a farm of hosts, but at a start at least localhost.
This is how I have set it up.
I have the docker plugin, and have configured a cloud on a remote machine, and the test button reports back a version, so my basic connectivity is there (i.e. remote access is correctly configured).
I have specified a template, which I can confirm is present on the remote dockerhost with “docker image ls”. It is built with “FROM jenkins/ssh-slave” and then a few apt-get lines.
I have choosen connectwith ssh and inject ssh key and the “jenkins” user (which has credentials in Jenkins already).
I have choosen pull strategy “never pull” so it will use the image I have at hand.
I have created a test job, pipetest, with a pipeline looking like this:
pipeline {
agent {
docker {
image "slavetest:latest"
}
}
stages {
stage('Build') {
steps {
git '<myrepo'
sh "go get ./..."
sh "go build ."
}
}
}
}
When I initiate a build I get this output:
Started by user Andreas Davour
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/jobs/pipetest/workspace
[Pipeline] {
[Pipeline] sh
+ docker inspect -f . slavetest:latest
/var/jenkins_home/jobs/pipetest/workspace@tmp/durable-db817775/script.sh: 1: /var/jenkins_home/jobs/pipetest/workspace@tmp/durable-db817775/script.sh: docker: not found
[Pipeline] sh
+ docker pull slavetest:latest
/var/jenkins_home/jobs/pipetest/workspace@tmp/durable-ff2f7ee1/script.sh: 1: /var/jenkins_home/jobs/pipetest/workspace@tmp/durable-ff2f7ee1/script.sh: docker: not found
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE
I can now see a dead container on my remote host, so the connectivity worked, but it did not run the commands I had in my stage. It looks like it’s trying to run the “docker” command within the remote container, not my build commands. I expected it to run “git” and “sh” and fail.
I am missing something obvious about how to set this up, but what?
I have specified a template, which I can confirm is present on the remote dockerhost with “docker image ls”. It is built with “FROM jenkins/ssh-slave” and then a few apt-get lines.
pipeline {
agent {
docker {
image "slavetest:latest"
}
}
The docker cli is not available in the master, as that is also containerized. Running containers in a container seems like defeating the purpose.
But, like two of you have mentioned, maybe this does not get spawned on my external docker host at all, which would be a problem. If that is the case, I’m really surprised, as the cloud I have configured for the plugin is a remote host.
There seems to be lot of pitfalls setting up this kind of setup. If someone has one and could write up a detailed description of how to set it up, that would be quite usable. I will, if I ever get this to work…
/andreas
From: jenkins...@googlegroups.com <jenkins...@googlegroups.com>
On Behalf Of Ivan Fernandez Calvo
Sent: den 5 april 2019 20:27
To: Jenkins Users <jenkins...@googlegroups.com>
Subject: [SOCIAL NETWORK] Re: Trying to setup jenkins to spin up docker containers on demand as build slaves in a pipeline - getting unclear errors
Unsubscribe
It appears that you have subscribed to commercial messages from this sender. To stop receiving such messages from this sender, please unsubscribe
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit
http://secure-web.cisco.com/1K-yULaFpe-kgW7pLJ_Pv9GkM9a50_K82v_UV_AO661yITxD65YPytS-2e3jtOvHA6VJQyVzzyUIUrsm-mWFNq0CVTaxjNRNhOT06voGNpaNNzksZznhhNzSQnOh_YnlOphurI5q70EIsUAeaQ0xxOpi28IxkjOF_0DUtrbEt33XqHwM4qwA6xXdTdx1mSb71KbBUWOq4Qhk4X7GHRBpxrl4nOQ3fSsvxTyWlo82GgMSB8ITEuEPTKWjvpRCX6aoCD_RZbTbhVQld0whfR9F9h0Lki_cFGmqpK46VeiVcUK_bt5ov3I3vmY7OG4slfD1wbxj5WmYEiB0hgmPIEAvHluiNrTaRYPd9fEJR_8R6IeFZL2o17sx71XLt3Lk_gSyS44WWr5mJb3IjlQjglZ2b1hNTe7Mh2fuUuESXimT53IKNuo6wlO-emHypORxm0xgcyZuNE-Txp3NCeTXT-lj4qhzS8rGs5qqVtsUVLcIP_oA/l105%3Ahttps%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fjenkinsci-users%2Ff3d5b590-cb72-493e-b3fd-a04a799ccf14%2540googlegroups.come.
For more options, visit
http://secure-web.cisco.com/1nP1q_KfLMe4cxqwUQatcJPyokqOyp_WwFyM4c9HN0UHNH8iy00tGbV-T1hKqHnBAxf8MiY74AvwEgtzdQvZQ5ewsmIR827RSRZ6fAwL_OVO6QVBFvDV8RQCCfLsjvpO6QlfqyVgYVCqxgtYw29btbWrvv809fQovruftox-yTBFZ6oMB8g9UVq8YizJANz7TdHJulxdqSjw4mo5OQbz-0xod1KpxNmkPnM93akBxOCfkz4RGaqlwjOaBTVCP0lwJN20ZwyVrJN1NXJK1L_SN5zBOaKa_3G3EIWXL6hzK7sgHRFrMMJtn3XZBm7xf3OUDe-1UN3owJ6aKKQPGlnjUKDuQfeUpgQSfoGFCgSug8rHFz8ZVbQ6ihTeTjFpFdwBij0OW_hI_ETXFNboHGA_QDlvvuz-9uSMXBTvS9FEaNjV4S9IFUj7Qvk2idBgdvM9lthTEYZ9LQAEo_Q8TJPggI86WAidJ2fuH9v69QLyC9To/l34%3Ahttps%3A%2F%2Fgroups.google.com%2Fd%2Foptoute.
I really don’t understand how on earth it could have been spawned on my master, as I have specifically pointed out the remote dockerhost as my only configured cloud! But, you might be right.
I have indeed intended to use labels to allocate nodes for jobs. I will try to use that instead of the image name, as suggested. Maybe it will at least give more indication of what works and not. Much appreciated!
/andreas
From: jenkins...@googlegroups.com <jenkins...@googlegroups.com>
On Behalf Of Zero Uno
Sent: den 5 april 2019 15:48
To: jenkins...@googlegroups.com
Subject: [SOCIAL NETWORK] Re: Trying to setup jenkins to spin up docker containers on demand as build slaves in a pipeline - getting unclear errors
Unsubscribe
It appears that you have subscribed to commercial messages from this sender. To stop receiving such messages from this sender, please unsubscribe
Il giorno mer 3 apr 2019 alle ore 16:53 'Andreas Davour' via Jenkins Users <jenkins...@googlegroups.com> ha scritto:
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit
http://secure-web.cisco.com/1aQJBWZLI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QjNsbxVDHBTYyNmvLQ/l34%3Ahttps%3A%2F%2Fgroups.google.com%2Fd%2Foptoute.