Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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:

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

<scm>
    <connection>scm:git:https://user:[email protected]/Project/project.git</connection>
    <developerConnection>scm:git:https://user:[email protected]/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.

like image 683
vbatista Avatar asked Mar 28 '16 17:03

vbatista


People also ask

How does Maven release plugin work?

The plugin will extract file revisions associated with the current release. Maven will compile, test and package the versioned project source code into an artifact. The final deliverable will then be released into an appropriate maven repository.

Does Maven plugin allows for release of Maven projects?

This plugin is used to release a project with Maven, saving a lot of repetitive, manual work. Releasing a project is made in two steps: prepare and perform. Note: Maven 3 users are encouraged to use at least Maven-3.0.

How do I run a Maven release?

Performing a release runs the following release phases by default: Checkout from an SCM URL with optional tag to workingDirectory ( target/checkout by default) Run the perform Maven goals to release the project (by default, deploy site-deploy ), eventually with release profile(s) active.

What is Maven SCM plugin?

The SCM Plugin offers vendor independent access to common scm commands by offering a set of command mappings for the configured scm. Each command is implemented as a goal.


2 Answers

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 :

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

Regards,

like image 143
bubulemaster Avatar answered Oct 30 '22 08:10

bubulemaster


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. 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:[email protected]/Project/project.git</connection>
    <developerConnection>scm:git:https://user:[email protected]/Project/project.git</developerConnection>

</scm>
like image 35
vbatista Avatar answered Oct 30 '22 06:10

vbatista