Currently we have a github repo where we store all the contracts, another repo which contains the producer code, and last but not least another one which contains the consumer code.
On the consumer side working with branches when pointing to the contract repo is well supported by using properties like stubrunner.properties.git.branch (more info can be found here https://cloud.spring.io/spring-cloud-contract/reference/html/appendix.html#additional-application-properties)
But on the producer I can not see any way of using the contracts of a concrete branch, we just can point to the github repo where contracts are stored by using contractsRepositoryUrl of the spring-cloud-contract-maven-plugin
This will be very useful to create a flow of contract testing :
UPDATE : the following spring-cloud-contract-maven-plugin config worked for me, also you can set this property through command line like this -Dstubrunner.properties.git.branch=other_branch_than_master
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>${spring-cloud-contract.version}</version>
<extensions>true</extensions>
<configuration>
<baseClassMappings>
<baseClassMapping>
<contractPackageRegex>.*rest.*</contractPackageRegex>
<baseClassFQN>com.xxx.yyy.contract.ContentCheckBaseTestClass</baseClassFQN>
</baseClassMapping>
</baseClassMappings>
<basePackageForTests>com.xxx.yyy.contract</basePackageForTests>
<contractsRepositoryUrl>git://https://github.com/xxx/yyy.git</contractsRepositoryUrl>
<contractsRepositoryUsername>${GITHUB_USER}</contractsRepositoryUsername>
<contractsRepositoryPassword>${GITHUB_TOKEN}</contractsRepositoryPassword>
<contractsMode>REMOTE</contractsMode>
<testMode>EXPLICIT</testMode>
<testFramework>JUNIT5</testFramework>
<contractsProperties>
<git.branch>another_branch</git.branch>
</contractsProperties>
<contractDependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</contractDependency>
</configuration>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>pushStubsToScm</goal>
</goals>
</execution>
</executions>
</plugin>
You can reuse the same properties presented here (https://docs.spring.io/spring-cloud-contract/docs/2.2.6.RELEASE/reference/html/appendix.html#additional-application-properties) under the e.g. Spring Cloud Contract Maven's <configuration><contractProperties>
section. That way you can pick which branch should be downloaded. Inside the plugin configuration:
<configuration>
<contractsProperties>
<git.branch>branchname</git.branch>
</contractsProperties>
</configuration>