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 49 forks source link

Cannot start agent after jcasc reload #79

Open antonlindahlcevt opened 4 years ago

antonlindahlcevt commented 4 years ago

Hello!

We are using the docker-swarm-plugin which seems to have some issue when reloading through jcasc. I cannot see any issue in the config.xml or in the gui but after an arbitary change in the gui our configuration works again. Getting the following error on the node:

ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins java.lang.NullPointerException at org.jenkinsci.plugins.docker.swarm.DockerSwarmCloud.getDockerSwarmApiUrl(DockerSwarmCloud.java:151) at org.jenkinsci.plugins.docker.swarm.docker.api.request.ApiRequest.<init>(ApiRequest.java:66) at org.jenkinsci.plugins.docker.swarm.docker.api.service.ServiceSpec.<init>(ServiceSpec.java:25) at org.jenkinsci.plugins.docker.swarm.DockerSwarmComputerLauncher.createCreateServiceRequest(DockerSwarmComputerLauncher.java:160) at org.jenkinsci.plugins.docker.swarm.DockerSwarmComputerLauncher.launchContainer(DockerSwarmComputerLauncher.java:119) at org.jenkinsci.plugins.docker.swarm.DockerSwarmComputerLauncher.launch(DockerSwarmComputerLauncher.java:101) at org.jenkinsci.plugins.docker.swarm.DockerSwarmComputerLauncher.launch(DockerSwarmComputerLauncher.java:56) at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:294) at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46) at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:71) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

What could miss being changed from jcasc? This is what is defined in the yaml file:

clouds:
  - dockerSwarm:
      agentTemplates:
      - baseWorkspaceLocation: "/home/runner"
        command: |-
          sh
          -cx
          wget -T 60 $DOCKER_SWARM_PLUGIN_JENKINS_AGENT_JAR_URL && java -jar agent.jar -jnlpUrl $DOCKER_SWARM_PLUGIN_JENKINS_AGENT_JNLP_URL -secret $DOCKER_SWARM_PLUGIN_JENKINS_AGENT_SECRET -noReconnect -workDir /home/tyrfing
        image: "our-server-computer:5000/latest-image:latest"
        label: "docker-image"
        limitsMemoryBytes: 0
        limitsNanoCPUs: 0
        osWindows: false
        placementConstraints: "node.role!=manager"
        pullCredentialsId: "3a7e52ef-ee88-46f3-a6d7-0bf9155ab697"
        reservationsMemoryBytes: 0
        reservationsNanoCPUs: 0
        serverAddress: "docker.swarm.se:5000"
        user: "root"
        workingDir: "/home/tyrfing"
      dockerHost:
        credentialsId: "DockerSwarm"
        uri: "https://docker.swarm.se:2376"
      dockerSwarmApiUrl: "https://docker.swarm.se:2376"
      jenkinsUrl: "http://our.jenkins.se:8080"

We are running jenkins in docker (jenkinsci/blueocean:latest) and have the Jenkins ver. 2.204.5 and configuration as code 1.36.