我创建了一个Jenkins管道 . 在这个管道中,我启动了一个Docker容器,并希望在这个启动的Docker容器中执行一些东西,但是我收到以下错误:

java.io.IOException: Failed to run image 'grme/nightwatch-chrome-firefox:1.0.0'. Error: docker: Error response from daemon: the working directory 'C:\Jenkins\workspace\FirstTest' is invalid, it needs to be an absolute path.

我的本地Jenkins服务器运行在我的本地Windows 10和Docker上,我已经安装在我的机器上 . 我'm able to pull the specific Docker image and I'能够通过 cmd 执行 docker run 命令 .

在另一个基于Unix的Jenkins服务器上,我没有这个问题 .

可能是什么问题以及如何解决?

这是我的Jenkins管道脚本:

pipeline {
    options {
        timestamps()
    }
    agent {
        node {
            label 'master'
        }
    }
    parameters {
        string(name: 'run_script_method', defaultValue: 'test', description: 'the run script method of npm')
        string(name: 'env_vars', defaultValue: '', description: 'the ENV variables to set before starting the tests')
    }
    stages {
      stage ('SETUP') {
        steps {
            script {
              cfg = load "./rest/jenkins/config.jenkins"
              mp = load "./rest/jenkins/jenkinslib.groovy"
            }
        }
      }
      stage ('TESTS') {
        steps {
            script {
              mp.configureLcmApplicationOrRunTests(cfg.environment.BETA, "${run_script_method}", "${env_vars}")
            }
        }
      }
    }
}

这是我用过的库,我实现了具体的函数 configureLcmApplicationOrRunTests

def configureLcmApplicationOrRunTests(
  Map args,
  NpmRunScriptMethod,
  AdditionalParameters
  ) {
      withDockerContainer(image: 'grme/nightwatch-chrome-firefox:1.0.0', args: "-e JAVA_OPTS=\"-Dselenium.LOGGER.level=WARNING\" -e NpmRunScriptMethod=\"$NpmRunScriptMethod\" -e AdditionalParameters=\"$AdditionalParameters\"") {
          sh """
            #set +x
            echo "======================================================================="
            pwd
            echo "$NpmRunScriptMethod"
            echo "$AdditionalParameters"
            echo "======================================================================="
            """
}