返回顶部

Jenkins+Ansible+Gitlab自动化部署三剑客(七)--Jenkins Maven集成

Jenkins maven集成

下载安装maven

1.打开maven官网:https://maven.apache.org/download.cgi

2.复制最新的maven软件包地址

http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz

 

 

 3.下载安装

 

 

 集成Maven

1.新建项目

 

 

 2.添加描述信息

 

 

 3.git选项

 

 

 

 

 

 

 

 

 4.全局工具配置

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 5.执行build

报错

Started by user admin
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/maven-freestyle-job
using credential 1bc88d18-1b1d-46e1-a8cb-0893d2c42e51
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://gitlab.example.com/root/java-war-dev.git # timeout=10
Fetching upstream changes from https://gitlab.example.com/root/java-war-dev.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress https://gitlab.example.com/root/java-war-dev.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision d9c5a412a64b53ecfb0f23e1740306b5c85c9256 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f d9c5a412a64b53ecfb0f23e1740306b5c85c9256 # timeout=10
Commit message: "First commit"
 > git rev-list --no-walk d9c5a412a64b53ecfb0f23e1740306b5c85c9256 # timeout=10
[maven-freestyle-job] $ /opt/apache-maven-3.6.3/bin/mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.140 s
[INFO] Finished at: 2020-02-22T12:56:37+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/var/lib/jenkins/workspace/maven-freestyle-job). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

原因:pom.xml文件不存在或者不在根目录下,这里pom.xml是需要自己创建的噢

 

 6.查看日志

 

posted @ 2020-02-22 17:51  Will_D_Zhang  阅读(278)  评论(0编辑  收藏  举报