简体   繁体   English

通过HTTPS在git上使用Maven-release-plugin

[英]Using maven-release-plugin with git over HTTPS

I am trying to use the maven release plugin with git over https(for some obscure reason, I can't use git over ssh), however, I am getting receiving the following error message: 我试图通过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]

Looking over the web, I have figured to set the following properties on my pom.xml file: 从网上看,我想在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>

And the following has been added to my settings.xml (located under ~/.m2 folder. I have checked that by running maven with -X flag) 并将以下内容添加到我的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>

Important note : If I add the user/password directly in connection and developerConnection attributes, like bellow, it works properly. 重要说明 :如果直接在connectiondeveloperConnection属性中添加用户/密码(例如波纹管),它将正常工作。

<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>

Is that correct? 那是对的吗? My guess is that the release plugin is not compatible with git over https however, I'd to get some confirmation about that. 我的猜测是发布插件与git over https不兼容,但是,我会对此进行一些确认。

I know this question is very old, but I discover it now. 我知道这个问题很老,但是现在发现了。 When you call maven prepare, you can set user and password in command line parameter : 调用maven prepare时,可以在命令行参数中设置用户和密码:

mvn release:prepare -DreleaseVersion=1.2 -DdevelopmentVersion=2.0-SNAPSHOT -Dtag=my-tag1.2 -Dusername=YYYYY -Dpassword=XXXXXX

Works with mavern-release-plugin 2.5.3 与mavern-release-plugin 2.5.3一起使用

Regards, 问候,

After some research, my conclusion is that the release plugin is not able to recover the password from external file when used with an https connection. 经过一些研究,我的结论是,当与https连接一起使用时,发布插件无法从外部文件中恢复密码。 So the best way I've found is to provide the password along the url, in the following format: 因此,我发现最好的方法是在网址中提供密码,格式如下:

<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.

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