代码之家  ›  专栏  ›  技术社区  ›  Hantsy

Spring Contract Maven插件pushstubstoscm不工作

  •  0
  • Hantsy  · 技术社区  · 7 年前

    我尝试在 生产者 边上传存根罐,与消费者分享。

    我使用的是SpringCloudContract 2.0.0。

    我配置了 Spring Cloud Contract Maven插件 在我的项目中, the codes is uploaded to Github .

    <plugin>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-contract-maven-plugin</artifactId>
        <version>${spring-cloud-contract.version}</version>
        <extensions>true</extensions>
        <configuration>
            <basePackageForTests>com.example.demo</basePackageForTests>
            <baseClassMappings>
                <baseClassMapping>
                    <contractPackageRegex>.*rest.*</contractPackageRegex>
                    <baseClassFQN>com.example.demo.RestVerifierBase</baseClassFQN>
                </baseClassMapping>
            </baseClassMappings>
            <!-- We want to pick contracts from a Git repository -->
            <!--<contractsRepositoryUrl>git://file://${project.basedir}/target/contract_git/</contractsRepositoryUrl>-->
            <!-- Example of URL via git protocol -->
            <!--<contractsRepositoryUrl>git://git@github.com:spring-cloud-samples/spring-cloud-contract-samples.git</contractsRepositoryUrl>-->
            <!-- Example of URL via http protocol -->
            <!--<contractsRepositoryUrl>git://https://github.com/spring-cloud-samples/spring-cloud-contract-samples.git</contractsRepositoryUrl>-->
    
            <contractsRepositoryUrl>git://https://github.com/hantsy/contracts-git.git</contractsRepositoryUrl>
            <!-- We reuse the contract dependency section to set up the path
            to the folder that contains the contract definitions. In our case the
            path will be /groupId/artifactId/version/contracts -->
            <contractDependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>${project.artifactId}</artifactId>
                <version>${project.version}</version>
            </contractDependency>
            <!-- The mode can't be classpath -->
            <contractsMode>REMOTE</contractsMode>
        </configuration>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <!-- By default we will not push the stubs back to SCM,
                    you have to explicitly add it as a goal -->
                    <goal>pushStubsToScm</goal>
                </goals>
            </execution>
        </executions>
    </plugin> 
    

    当我执行命令时 mvn clean install -DskipTests -DcontractsRepositoryUsername=hantsy -DcontractsRepositoryPassword=mypassword 然后失败了。

    Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/hantsy/contracts-git.git: Authentication is required but no CredentialsProvider has been registered
    

    更新 :如果我设置 contractsMode 对于本地,它将失败,因为下载stubs jar错误,可能与 this issue 在新版本2.0.0中,当 斯塔斯莫德 设置为本地。

    更新2 :我还试图添加 合同地址用户名称 合同保证金密码 在SpringContract Maven插件配置中,它不起作用。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Marcin Grzejszczak    7 年前

    contractsMode 需要 REMOTE .我举了你的例子,它很好地适用于:

    <contractsRepositoryUrl>git://git@github.com:marcingrzejszczak/contracts-git.git</contractsRepositoryUrl>
    <contractsMode>REMOTE</contractsMode>
    

    通过手动传递证书,我看到了一件非常奇怪的事情…

    我懂了 [INFO] Passed username and password - will set a custom credentials provider 这意味着用户名和密码已经通过,我正在使用它们。但实际上我得到的是 Authentication is required but no CredentialsProvider has been registered 这是毫无意义的。你能为那个再提交一个bug吗?解决方法是使用代理。

    更新:

    问题在这里解决了 https://github.com/spring-cloud/spring-cloud-contract/issues/678