[英]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
文件夾下。我已經通過使用-X
標志運行maven進行了檢查)
<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
屬性中添加用戶/密碼(例如波紋管),它將正常工作。
<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>
那是對的嗎? 我的猜測是發布插件與git over https不兼容,但是,我會對此進行一些確認。
我知道這個問題很老,但是現在發現了。 調用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連接一起使用時,發布插件無法從外部文件中恢復密碼。 因此,我發現最好的方法是在網址中提供密碼,格式如下:
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.