spring-cloud-contract icon indicating copy to clipboard operation
spring-cloud-contract copied to clipboard

Set contract repository credentials in settings.xml

Open hantsy opened this issue 6 years ago • 7 comments

Mentioned in https://github.com/spring-cloud/spring-cloud-contract/issues/678.

If possible set username and password in servers section in local settings.xml file, and let spring cloud contract maven plugin refer to the id of the server definition in the project pom.xml, thus it will not expose credentials to public.

hantsy avatar Jul 03 '18 08:07 hantsy

Related to https://github.com/spring-cloud/spring-cloud-contract/issues/285

marcingrzejszczak avatar Jul 03 '18 08:07 marcingrzejszczak

Which servers should it pick? I guess we would need to pass the server id or sth.

marcingrzejszczak avatar Jul 03 '18 08:07 marcingrzejszczak

Define username/password personal settings.xml. https://maven.apache.org/settings.html

Yes, pick a server id in Spring Contract mavenplugin.

An example: http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/usage.html

<plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.0</version>
        <configuration>
          <server>myserver</server>
        </configuration>
      </plugin>

Credentials in settings.xml


<settings>
  ...
  <servers>
    ...
    <server>
      <id>myserver</id>
      <username>myusername</username>
      <password>mypassword</password>
    </server>
    ...
  </servers>
  ...
</settings>

hantsy avatar Jul 03 '18 08:07 hantsy

+1 what the status of this? I'm try to push to the private repository.

Hronom avatar Sep 02 '18 22:09 Hronom

You can pass creds manually. We're not reading them from settings.xml

marcingrzejszczak avatar Sep 03 '18 05:09 marcingrzejszczak

Ok, thanks for help.

@marcingrzejszczak What the status of supporting passing of it through settings.xml, since it created for storing user related settings and it's the common way in maven to handle stuff like this.

Proposed solution by @hantsy is acceptable for me.

Here is another proposition: For example you have:

            <plugin>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-contract-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <baseClassForTests>com.example.ServiceAppTest</baseClassForTests>
                    <contractsRepositoryUrl>git://https://gitlab.com/Hronom/services-stubs.git</contractsRepositoryUrl>
                </configuration>
            </plugin>

For this config plugin will ask server in settings.xml:

<settings>
  ...
  <servers>
    ...
    <server>
      <id>https://gitlab.com/Hronom/services-stubs.git</id>
      <username>myusername</username>
      <password>mypassword</password>
    </server>
    ...
  </servers>
  ...
</settings>

Hronom avatar Sep 03 '18 07:09 Hronom

No work has been done yet.

marcingrzejszczak avatar Sep 03 '18 08:09 marcingrzejszczak