我正在尝试建立一个管道来构建在github上提交的java maven项目管道。
我已经在Windows机器上安装了詹金斯。
我的管道在以下阶段被击中

Started by user Akshay Katti
Obtained Jenkinsfile from git C:\Users\ak186148\git\Kylo-Accelerator
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in C:\Users\ak186148\.jenkins\workspace\Kylo-Promoter-CI-CD
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
 > git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git.exe config remote.origin.url C:\Users\ak186148\git\Kylo-Accelerator # timeout=10
Fetching upstream changes from C:\Users\ak186148\git\Kylo-Accelerator
 > git.exe --version # timeout=10
 > git.exe fetch --tags --progress C:\Users\ak186148\git\Kylo-Accelerator +refs/heads/*:refs/remotes/origin/*
 > git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision e8ad0282a7fbd877461b3866a15f0116b2848065 (refs/remotes/origin/master)
 > git.exe config core.sparsecheckout # timeout=10
 > git.exe checkout -f e8ad0282a7fbd877461b3866a15f0116b2848065
Commit message: "Add initial Jenkinsfile"
 > git.exe rev-list --no-walk e8ad0282a7fbd877461b3866a15f0116b2848065 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
[C:\Users\ak186148\.jenkins\workspace\Kylo-Promoter-CI-CD] Running shell script
nohup: failed to run command 'sh': No such file or directory
process apparently never started in C:\Users\ak186148\.jenkins\workspace\Kylo-Promoter-CI-CD@tmp\durable-b24ab647
[Pipeline] sh
[C:\Users\ak186148\.jenkins\workspace\Kylo-Promoter-CI-CD] Running shell script
nohup: failed to run command 'sh': No such file or directory
process apparently never started in C:\Users\ak186148\.jenkins\workspace\Kylo-Promoter-CI-CD@tmp\durable-5e2947b3
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code -2
Finished: FAILURE


请在附件中找到我的Jenkinsfile(我从sh更改为bat)

pipeline {
    agent {
        docker {
            image 'maven:3-alpine'
            args '-v /root/.m2:/root/.m2'
        }
    }
    stages {
        stage('Build')
        {
            steps {
                bat 'mvn -B -DskipTests clean package'
            }
        }
    }
}


也请在下面的错误中找到蓝海页面上的错误
blue_ocean_error

请帮忙。

最佳答案

我不确定您能否在Windows上轻松运行它。

对我来说,问题是正确的nohup不在PATH上。

为了调试该问题,我在创建包含内容的文件java -Djava.util.logging.config.file=logging.properties -jar jenkins.war后启动了logging.properties

org.jenkinsci.plugins.durabletask.level=FINE
handlers= java.util.logging.ConsoleHandler

java.util.logging.ConsoleHandler.level=FINE
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter


之后,我将nohup(和sh ...)从C:\Program Files\Git\usr\bin添加到PATH。



即使将驱动器C:设置为Docker设置中的共享驱动器,也没有任何改善。

$ docker run -t -d -u 197609:197121 \
-w C:\Users\A\.jenkins\workspace\Multibranch_pipeline_master@2 \
-v C:\Users\A\.jenkins\workspace\Multibranch_pipeline_master@2:C:\Users\A\.jenkins\workspace\Multibranch_pipeline_master@2:rw,z \
-v C:\Users\A\.jenkins\workspace\Multibranch_pipeline_master@2@tmp:C:\Users\A\.jenkins\workspace\Multibranch_pipeline_master@2@tmp:rw,z \
-e ******** ... \
maven:3.3.3 cat

java.io.IOException: Failed to run image 'maven:3.3.3'.
  Error: docker: Error response from daemon: the working directory
  'C:\Users\A\.jenkins\workspace\Multibranch_pipeline_master@2' is invalid,
  it needs to be an absolute path.


因此,使用的路径应类似于/C/...而不是C:\...

09-28 12:46
查看更多