通过 HTTPS 使用带有 git 的 maven-release-plugin
Using maven-release-plugin with git over HTTPS
我正在尝试通过 https 使用带有 git 的 Maven 发布插件(由于某些不明原因,我无法通过 ssh 使用 git),但是,我收到以下信息错误信息:
14:36:52 [ERROR] The git-push command failed.
14:36:52 [ERROR] Command output:
14:36:52 [ERROR] fatal: could not read Username for 'https://my.company.git.host.com': No such device or address
14:36:52 [ERROR] -> [Help 1]
浏览网页,我想在我的 pom.xml 文件中设置以下属性:
<scm>
<connection>scm:git:https://my.company.git.host.com/Project/project.git</connection>
<developerConnection>scm:git:https://my.company.git.host.com/Project/project.git</developerConnection>
</scm>
并且以下内容已添加到我的 settings.xml(位于 ~/.m2
文件夹下。我已通过 运行 maven 检查过-X
标志)
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>my.company.git.host.com</id>
<username>svc.jenkins.project</username>
<password>guesswhat</password>
</server>
</servers>
</settings>
重要说明:
如果我直接在 connection
和 developerConnection
属性中添加 user/password,如下所示,它可以正常工作。
<scm>
<connection>scm:git:https://user:password@my.company.git.host.com/Project/project.git</connection>
<developerConnection>scm:git:https://user:password@my.company.git.host.com/Project/project.git</developerConnection>
</scm>
对吗?我的猜测是发布插件与 https 上的 git 不兼容,但是,我会得到一些确认。
经过一些研究,我的结论是发布插件在与 https 连接一起使用时无法从外部文件恢复密码。所以我发现的最好方法是在 url 中提供密码,格式如下:
<scm>
<connection>scm:git:https://user:password@my.company.git.host.com/Project/project.git</connection>
<developerConnection>scm:git:https://user:password@my.company.git.host.com/Project/project.git</developerConnection>
</scm>
我知道这个问题很老,但我现在发现了。调用maven prepare时,可以在命令行参数中设置用户和密码:
mvn release:prepare -DreleaseVersion=1.2 -DdevelopmentVersion=2.0-SNAPSHOT -Dtag=my-tag1.2 -Dusername=YYYYY -Dpassword=XXXXXX
适用于 mavern-release-plugin 2.5.3
此致,
我正在尝试通过 https 使用带有 git 的 Maven 发布插件(由于某些不明原因,我无法通过 ssh 使用 git),但是,我收到以下信息错误信息:
14:36:52 [ERROR] The git-push command failed.
14:36:52 [ERROR] Command output:
14:36:52 [ERROR] fatal: could not read Username for 'https://my.company.git.host.com': No such device or address
14:36:52 [ERROR] -> [Help 1]
浏览网页,我想在我的 pom.xml 文件中设置以下属性:
<scm>
<connection>scm:git:https://my.company.git.host.com/Project/project.git</connection>
<developerConnection>scm:git:https://my.company.git.host.com/Project/project.git</developerConnection>
</scm>
并且以下内容已添加到我的 settings.xml(位于 ~/.m2
文件夹下。我已通过 运行 maven 检查过-X
标志)
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>my.company.git.host.com</id>
<username>svc.jenkins.project</username>
<password>guesswhat</password>
</server>
</servers>
</settings>
重要说明:
如果我直接在 connection
和 developerConnection
属性中添加 user/password,如下所示,它可以正常工作。
<scm>
<connection>scm:git:https://user:password@my.company.git.host.com/Project/project.git</connection>
<developerConnection>scm:git:https://user:password@my.company.git.host.com/Project/project.git</developerConnection>
</scm>
对吗?我的猜测是发布插件与 https 上的 git 不兼容,但是,我会得到一些确认。
经过一些研究,我的结论是发布插件在与 https 连接一起使用时无法从外部文件恢复密码。所以我发现的最好方法是在 url 中提供密码,格式如下:
<scm>
<connection>scm:git:https://user:password@my.company.git.host.com/Project/project.git</connection>
<developerConnection>scm:git:https://user:password@my.company.git.host.com/Project/project.git</developerConnection>
</scm>
我知道这个问题很老,但我现在发现了。调用maven prepare时,可以在命令行参数中设置用户和密码:
mvn release:prepare -DreleaseVersion=1.2 -DdevelopmentVersion=2.0-SNAPSHOT -Dtag=my-tag1.2 -Dusername=YYYYY -Dpassword=XXXXXX
适用于 mavern-release-plugin 2.5.3
此致,