我正在尝试构建管道,以构建在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
请帮助。
答案 0 :(得分:0)
我不确定您能否在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:\...
。
答案 1 :(得分:0)
这个“进程显然从未开始”是一个可能有不同原因的通用错误,因此:
org.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true
在 Jenkins 的脚本控制台中进行调试(需要是 Jenkins 管理员),然后重新启动您的作业以查看作业控制台输出中是否有有用的新信息org.jenkinsci.plugins.durabletask
的日志记录器并重新启动您的工作,看看您的自定义日志记录器中是否有有用的新信息。就我而言,通过系统控制台激活 LAUNCH_DIAGNOSTICS
给了我以下错误:
nohup:不可能的 d'executer la commande « sh »:Aucun fichier ou dossier de ce type
显然,PATH 有问题。 This answer on a similar question然后帮助我注意到这是由系统配置页面中的PATH环境变量的修改引起的。