15

I am using the Jenkins Azure VM Agents Plugin with a Linux Master, to launch jobs on Windows agents.

I have been through all the configuration steps and everything works fine until I try to use Docker on the agents.

My pipeline script:

pipeline {
    agent {
        docker {
            image 'myurl.io/myimage:latest'
            registryUrl 'https://myurl.io/'
            registryCredentialsId '123456789abcdefg'
        }
    }

The pipeline appears to fails on when it runs this command:

docker pull myurl.io/myimage:latest

The error reported comes down to this:

Caused: java.io.IOException: Cannot run program "nohup" (in directory "C:\Jenkins\workspace\Test Pipeline Docker"): CreateProcess error=2, The system cannot find the file specified

Some notes:

  • I have ticked the box to install git on the image: enter image description here

  • The Git tools appear to be successfully installed on the agent VM

  • This question seems to be related but is it not exactly the same

    • I am not running the sh command directly, it is being run by the plugin.
    • I do not think I have access to set the PATH at this stage
  • This issue on JIRA https://issues.jenkins-ci.org/browse/JENKINS-36776 is related, but it does not seems to be fixed and the suggested workarounds don't seem to apply to my situation

My question

Is there a way to get my pipeline script to work? Maybe there are some extra commands I can somehow execute on the agent after it launches - but before the docker pull command - to add the required directories to the PATH?

Or is there some other workaround?

Captain Whippet
  • 2,143
  • 4
  • 25
  • 34
  • Interested, I have same problem. Did you resolved? – realtebo Jul 08 '18 at 14:13
  • 1
    @realtebo No, I haven't resolved it yet, but I haven't tried again for a while. – Captain Whippet Jul 09 '18 at 08:11
  • Might it be possible to provide a file `nohup.bat` which just executes all of its parameters normally to resolve the absence of `nohup` on Windows? – linux-fan Nov 02 '19 at 01:03
  • I am going to with `nohup` is a unix command and the agent is a Win server. Search S/O for ["[jenkins] nohup 'c:\' is:question"](https://stackoverflow.com/search?q=%5Bjenkins%5D+nohup+%27c%3A%5C%27+is%3Aquestion) for suggestions to fix. – Ian W Oct 22 '20 at 09:24
  • it looks like your Jenkins slave cannot access the nohup command on your machine. Have you checked your Jenkins in the configuration --> tools where is the path of your git-tools? – randytan Jun 29 '21 at 14:56

1 Answers1

1

I think you were on the right track with the question you already found: Jenkins pipeline sh fail with "cannot run program nohup" on windows

But, according to the wiki page of the docker-pipeline plugin, running docker on windows workers is not supported (a bit hidden though...):

For Jenkins environments which have macOS, Windows, or other agents, which are unable to run the Docker daemon, this default setting may be problematic. [https://www.jenkins.io/doc/book/pipeline/docker/#specifying-a-docker-label]

As far as I can see, there were several tries to add that feature, but it doesn't seem to be added (yet): https://github.com/jenkinsci/docker-workflow-plugin/pull/148

In the last link it is also stated, that fixing the sh/nohup issue will not be your only problem, for example the docker plugin will try to run id to get the user.

Nevertheless, you could try to make linux commands available by editing the path in your pipeline declaration: https://stackoverflow.com/a/45101214/12338776

EDIT: Just saw this question is 3 years old... Well. But since there was no answer so far, and a lot of people still seem to get here, it might still help someone.

thetillhoff
  • 451
  • 4
  • 8