KostyaSha / yet-another-docker-plugin

Jenkins Yet Another Docker Plugin
https://plugins.jenkins.io/yet-another-docker-plugin
MIT License
83 stars 48 forks source link

Declarative Pipeline Syntax Support #169

Open Starefossen opened 7 years ago

Starefossen commented 7 years ago

Have anyone go this to work with the new Declarative Jenkins Pipelines? I am having a hard time getting Jenkins to receive any cloud provisioning requests with the new syntax.

pipeline {                                        
  agent { node { label 'docker-node' } }
  ...
vasya10 commented 7 years ago

Have you tried

pipeline { agent { label 'docker-node' } }

Starefossen commented 7 years ago

Stil nothing, stuck at There are no nodes with the label ‘docker-node’ 😒

vasya10 commented 7 years ago

You can try a few debug steps. Check the following:

  1. docker logs -f and see if any exceptions are thrown (I occasionally see IllegalStateException mostly due to a wrong property i set)
  2. Try using Netty instead of Jersey in YADP plugin config
  3. Try using JNLP instead of SSH in YADP plugin config
  4. Is your Docker URL set to tcp://:2375 ? So your container can communicate with Docker Host?
  5. If you use a private registry that is self signed, you have to add --insecure-registry to DOCKER_OPTS
  6. In create container settings in yadp plugin config, ensure volume has /var/run/docker.sock mounted.

We got a declarative jenkins pipeline working with artifactory and yadp configuration.

KostyaSha commented 7 years ago

Firstly try with static slave as label, then replace with cloud label. Label will be missing because there is no slaves, Cloud API will request new node for label. And then if something fails slave wouldn't be created. Check Cloud statistics page in global settings.

KostyaSha commented 7 years ago

Try using Netty instead of Jersey in YADP plugin config

Vice versa, jersey is more stable unfortunately :(

Starefossen commented 7 years ago

Thanks for all the help both of you! I completely removed the cloud and set it up again. Then I ran in to an (unrelated) connection issue with JNLP (probably due to port forwarding / firewalls) and had to get SSH working instead.

I am using a modified version of the jenkins/ssh-slave:latest (our fork) which has the "correct" uid and gid for the jenkins user to match what is on the host to be able to share workspaces between containers. It also has docker client cli installed to make the Docker Pipeline Plugin work as well.

I have not yet been able to get the Docker Pipeline Plugin working with Declarative Jenkins Pipelines which means I had to revert back to the old pipeline syntax (for now). Thanks for all the help!

KostyaSha commented 7 years ago

I am using a modified version of the jenkins/ssh-slave:latest (our fork) which has the "correct" uid and gid for the jenkins user to match what is on the host to be able to share workspaces between containers. It also has docker client cli installed to make the Docker Pipeline Plugin work as well.

Never used jenkins-ssh-slave and other docker images, i can suggest to do own images. It a good question about making user for getting permission for mount. I made experimental dockerShell step for executing ssh command in container with mounted workspace, maybe it can help future...