1.项目使用maven的时候,首先在Global Tool Configuration里面添加自动安装maven,然后在项目的构建中增加Invoke top-level Maven targets中的Maven Version里面选中刚刚添加的Maven ID,否则会报以下错误:
FATAL: command execution failed java.io.IOException: Cannot run program "mvn" (in directory "/var/jenkins_home/workspace/JettyDocker"): error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at hudson.Proc$LocalProc.<init>(Proc.java:240) at hudson.Proc$LocalProc.<init>(Proc.java:212) at hudson.Launcher$LocalLauncher.launch(Launcher.java:815) at hudson.Launcher$ProcStarter.start(Launcher.java:381) at hudson.Launcher$ProcStarter.join(Launcher.java:388) at hudson.tasks.Maven.perform(Maven.java:331) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779) at hudson.model.Build$BuildExecution.build(Build.java:205) at hudson.model.Build$BuildExecution.doRun(Build.java:162) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534) at hudson.model.Run.execute(Run.java:1741) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:410) Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:248) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 15 more
2.巨坑:
在上图kitematic界面中点击右下侧任意一个路径,会弹出如图对话框,若选择Enable Volumes会发生四件坏事:
1.强制重启jenkins server,即便有job没有完成;
2.重启后需要重新安装jenkins插件;
3.导致jenkins无法使用DooD的docker命令。
3.admin用户的密码会改变。
所以切记任何时候使用jenkins容器不要点选enable volumes。
解决办法:
停止(删除)docker,重新运行以下命令并配置新的jenkins容器。
docker run - d - v / var / run / docker . sock : / var / run / docker . sock \