简体   繁体   English

使用Jenkins Pipeline发布Maven

[英]Maven Release using Jenkins Pipeline

I'm currently trying to use Jenkins Pipeline to deploy the project I'm working on. 我目前正在尝试使用Jenkins Pipeline部署我正在从事的项目。

The problem appears when I use the following commands: 使用以下命令时出现问题:

stage("Prepare") {
     sh "mvn -B -s $MAVEN_SETTINGS release:prepare -DreleaseVersion=$releaseVersion -DdevelopmentVersion=$developmentVersion"
}

I receive this error: 我收到此错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release- plugin:2.5:prepare (default-cli) on project *my_project*: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-add command failed.
[ERROR] Command output:
[ERROR] /bin/sh: git: not found

As you can see, the error is caused by the git add command, which can't be performed. 如您所见,该错误是由git add命令引起的,无法执行。 I have to mention that in a previous stage, in the script, I successfully clone the project, by using a git url: command. 我不得不提到,在上一个阶段的脚本中,我使用git url:命令成功克隆了项目。 However, if I try a simple git command, like sh "git --version" , I get git: not found . 但是,如果我尝试一个简单的git命令,例如sh "git --version" ,则会得到git: not found

So, my question: 所以,我的问题是:

In order to be able to use mvn command, I used the next command: 为了能够使用mvn命令,我使用了下一个命令:

env.PATH = "${tool 'maven 3.0.5'}/bin:${env.PATH}"

Is it possible to do the same, or any other solution, for git, such that the mvn release:prepare will be able to run git add? 是否可以对git执行相同或任何其他解决方案,以使mvn release:prepare能够运行git add?

Thank you. 谢谢。

我最终基于安装了git的映像在docker容器上运行命令,因为我无权在Jenkins上安装git。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM