如何在Jenkins上成功构建我的maven应用程序



我是詹金斯的新手,运气不太好。我正在尝试用maven构建我的spring-boot应用程序;clean compile package";在Invoke顶级Maven目标中。

生成失败。

Started by user unknown or anonymous
Running as SYSTEM
Building in workspace /var/jenkins_home/jobs/sample/workspace
The recommended git tool is: NONE
No credentials specified
> git rev-parse --resolve-git-dir /var/jenkins_home/jobs/sample/workspace/.git # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/rshncp/stackApp.git # timeout=10
Fetching upstream changes from https://github.com/rshncp/stackApp.git
> git --version # timeout=10
> git --version # 'git version 2.30.2'
> git fetch --tags --force --progress -- https://github.com/rshncp/stackApp.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/main^{commit} # timeout=10
Checking out Revision 497d77eeef33f9cc19c5390d21cf49e90ac24e05 (refs/remotes/origin/main)
> git config core.sparsecheckout # timeout=10
> git checkout -f 497d77eeef33f9cc19c5390d21cf49e90ac24e05 # timeout=10
Commit message: "first commit"
> git rev-list --no-walk 497d77eeef33f9cc19c5390d21cf49e90ac24e05 # timeout=10
[workspace] $ mvn clean compile package
FATAL: command execution failed
java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
Caused: java.io.IOException: Cannot run program "mvn" (in directory "/var/jenkins_home/jobs/sample/workspace"): error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:995)
at hudson.Launcher$ProcStarter.start(Launcher.java:507)
at hudson.Launcher$ProcStarter.join(Launcher.java:518)
at hudson.tasks.Maven.perform(Maven.java:367)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:806)
at hudson.model.Build$BuildExecution.build(Build.java:198)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:514)
at hudson.model.Run.execute(Run.java:1888)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:99)
at hudson.model.Executor.run(Executor.java:431)
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

我该怎么解决这个问题?

  1. 下载Maven作为插件。您必须转到Jenkins Global Tool Configuration,并使用自动安装程序(从web(配置Maven版本
  2. 在全局配置中安装,maven版本。看看这个案例的第二个答案"无法运行程序";mvn";error=2,没有这样的文件或目录

最新更新