Skip to content

Commit

Permalink
update apps to pact-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
schwen authored and ArneLimburg committed Nov 7, 2024
1 parent f12d80f commit c732329
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 8 deletions.
5 changes: 4 additions & 1 deletion address-validation-service/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pipeline {
RELEASE_VERSION = "${env.SNAPSHOT_VERSION.contains('-SNAPSHOT') ? env.SNAPSHOT_VERSION.substring(0, env.SNAPSHOT_VERSION.lastIndexOf('-SNAPSHOT')) : SNAPSHOT_VERSION}"
VERSION = "${env.BRANCH_NAME == 'main' && !env.LAST_COMMIT_MESSAGE.startsWith('update version to ') ? env.RELEASE_VERSION : env.SNAPSHOT_VERSION}"
ROOT_DIRECTORY = "${params.verifyPacts == true && env.BRANCH_NAME == 'main' && env.SNAPSHOT_VERSION.endsWith("-SNAPSHOT") ? 'target/checkout' : '.'}"
STAGE = "${env.BRANCH_NAME == 'main' ? 'prod' : 'test'}"
}

triggers {
Expand Down Expand Up @@ -71,7 +72,7 @@ pipeline {
steps {
sh """
cd ${ROOT_DIRECTORY}
mvn test -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -B
mvn test -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -Dpact.tag=${params.verifyPacts ? 'pending-' + env.STAGE : env.STAGE} -B
"""
}
}
Expand Down Expand Up @@ -149,6 +150,8 @@ pipeline {
&& ~/address-validation-service-distribution/bin/meecrowave.sh start"
"""
}
sh "curl -H 'Content-Type: application/json' -X PUT http://pact-service:8080/pacticipants/address-validation-service/versions/${env.VERSION}/tags/${env.STAGE}"
sh "curl -X DELETE http://pact-service:8080/pacticipants/address-validation-service/versions/${env.VERSION}/tags/pending-${env.STAGE}"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions address-validation-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<pactBroker.url>http://localhost:5000</pactBroker.url>
<pact.tag>develop</pact.tag>
<meecrowave.version>1.2.13</meecrowave.version>
<junit.version>5.8.2</junit.version>
</properties>
Expand Down Expand Up @@ -84,6 +85,7 @@
<configuration>
<systemPropertyVariables>
<pact.provider.version>${project.version}</pact.provider.version>
<pact.tag>${pact.tag}</pact.tag>
<pactBroker.url>${pactBroker.url}</pactBroker.url>
</systemPropertyVariables>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
import au.com.dius.pact.provider.junitsupport.Provider;
import au.com.dius.pact.provider.junitsupport.State;
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
import au.com.dius.pact.provider.junitsupport.loader.VersionSelector;

@IgnoreNoPactsToVerify
@Provider("address-validation-service")
@PactBroker(url = "${pactBroker.url:http://localhost:5000}")
@PactBroker(url = "${pactBroker.url:http://localhost:5000}", consumerVersionSelectors = @VersionSelector(tag = "${pact.tag}"))
@MonoMeecrowaveConfig
public class AddressValidationServiceTest {

Expand Down
5 changes: 4 additions & 1 deletion billing-service/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pipeline {
RELEASE_VERSION = "${env.SNAPSHOT_VERSION.contains('-SNAPSHOT') ? env.SNAPSHOT_VERSION.substring(0, env.SNAPSHOT_VERSION.lastIndexOf('-SNAPSHOT')) : SNAPSHOT_VERSION}"
VERSION = "${env.BRANCH_NAME == 'main' && !env.LAST_COMMIT_MESSAGE.startsWith('update version to ') ? env.RELEASE_VERSION : env.SNAPSHOT_VERSION}"
ROOT_DIRECTORY = "${params.verifyPacts == true && env.BRANCH_NAME == 'main' && env.SNAPSHOT_VERSION.endsWith("-SNAPSHOT") ? 'target/checkout' : '.'}"
STAGE = "${env.BRANCH_NAME == 'main' ? 'prod' : 'test'}"
}

triggers {
Expand Down Expand Up @@ -71,7 +72,7 @@ pipeline {
steps {
sh """
cd ${ROOT_DIRECTORY}
mvn test -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -B
mvn test -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -Dpact.tag=${params.verifyPacts ? 'pending-' + env.STAGE : env.STAGE} -B
"""
}
}
Expand Down Expand Up @@ -149,6 +150,8 @@ pipeline {
&& ~/billing-service-distribution/bin/meecrowave.sh start"
"""
}
sh "curl -H 'Content-Type: application/json' -X PUT http://pact-service:8080/pacticipants/billing-service/versions/${env.VERSION}/tags/${env.STAGE}"
sh "curl -X DELETE http://pact-service:8080/pacticipants/billing-service/versions/${env.VERSION}/tags/pending-${env.STAGE}"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions billing-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<pactBroker.url>http://localhost:5000</pactBroker.url>
<pact.tag>develop</pact.tag>
<meecrowave.version>1.2.13</meecrowave.version>
<junit.version>5.8.2</junit.version>
</properties>
Expand Down Expand Up @@ -90,6 +91,7 @@
<configuration>
<systemPropertyVariables>
<pact.provider.version>${project.version}</pact.provider.version>
<pact.tag>${pact.tag}</pact.tag>
<pactBroker.url>${pactBroker.url}</pactBroker.url>
</systemPropertyVariables>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
import au.com.dius.pact.provider.junitsupport.Provider;
import au.com.dius.pact.provider.junitsupport.State;
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
import au.com.dius.pact.provider.junitsupport.loader.VersionSelector;

@IgnoreNoPactsToVerify
@Provider("billing-service")
@PactBroker(url = "${pactBroker.url:http://localhost:5000}")
@PactBroker(url = "${pactBroker.url:http://localhost:5000}", consumerVersionSelectors = @VersionSelector(tag = "${pact.tag}"))
@MonoMeecrowaveConfig
public class BillingAddressServiceTest {

Expand Down
6 changes: 5 additions & 1 deletion customer-service/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pipeline {
PERFORM_RELEASE = "${env.SNAPSHOT_VERSION.contains('-SNAPSHOT') && env.BRANCH_NAME == 'main' && !env.LAST_COMMIT_MESSAGE.startsWith('update version to ')}"
RELEASE_VERSION = "${env.SNAPSHOT_VERSION.contains('-SNAPSHOT') ? env.SNAPSHOT_VERSION.substring(0, env.SNAPSHOT_VERSION.lastIndexOf('-SNAPSHOT')) : SNAPSHOT_VERSION}"
VERSION = "${env.BRANCH_NAME == 'main' && !env.LAST_COMMIT_MESSAGE.startsWith('update version to ') ? env.RELEASE_VERSION : env.SNAPSHOT_VERSION}"
STAGE = "${env.BRANCH_NAME == 'main' ? 'prod' : 'test'}"
}

triggers {
Expand Down Expand Up @@ -48,7 +49,7 @@ pipeline {
}
}
steps {
sh 'mvn test pact:publish -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -B'
sh 'mvn test pact:publish -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -Dpact.consumer.tags=pending-${env.STAGE} -B'
}
}
stage ('Test providers') {
Expand Down Expand Up @@ -136,8 +137,11 @@ pipeline {
&& ~/customer-service-distribution/bin/meecrowave.sh start"
"""
}
sh "curl -H 'Content-Type: application/json' -X PUT http://pact-service:8080/pacticipants/customer-service/versions/${env.VERSION}/tags/${env.STAGE}"
sh "curl -X DELETE http://pact-service:8080/pacticipants/customer-service/versions/${env.VERSION}/tags/pending-${env.STAGE}"
}
}
}
}
}

7 changes: 5 additions & 2 deletions delivery-service/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pipeline {
RELEASE_VERSION = "${env.SNAPSHOT_VERSION.contains('-SNAPSHOT') ? env.SNAPSHOT_VERSION.substring(0, env.SNAPSHOT_VERSION.lastIndexOf('-SNAPSHOT')) : SNAPSHOT_VERSION}"
VERSION = "${env.BRANCH_NAME == 'main' && !env.LAST_COMMIT_MESSAGE.startsWith('update version to ') ? env.RELEASE_VERSION : env.SNAPSHOT_VERSION}"
ROOT_DIRECTORY = "${params.verifyPacts == true && env.BRANCH_NAME == 'main' && env.SNAPSHOT_VERSION.endsWith("-SNAPSHOT") ? 'target/checkout' : '.'}"
STAGE = "${env.BRANCH_NAME == 'main' ? 'prod' : 'test'}"
}

triggers {
Expand Down Expand Up @@ -71,7 +72,7 @@ pipeline {
steps {
sh """
cd ${ROOT_DIRECTORY}
mvn test -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -B
mvn test -DpactBroker.url=http://pact:9292 -Dpact.verifier.publishResults=true -Dpact.tag=${params.verifyPacts ? 'pending-' + env.STAGE : env.STAGE} -B
"""
}
}
Expand All @@ -88,7 +89,7 @@ pipeline {
}
}
steps {
sh 'mvn pact:publish -DpactBroker.url=http://pact-service:8080 -Dpact.verifier.publishResults=true -B'
sh "mvn pact:publish -DpactBroker.url=http://pact-service:8080 -Dpact.verifier.publishResults=true -Dpact.consumer.tags=pending-${env.STAGE} -B"
build job: "address-validation-service/${env.BRANCH_NAME}", parameters: [booleanParam(name: 'verifyPacts', value: true)]
}
}
Expand Down Expand Up @@ -166,6 +167,8 @@ pipeline {
&& ~/delivery-service-distribution/bin/meecrowave.sh start"
"""
}
sh "curl -H 'Content-Type: application/json' -X PUT http://pact-service:8080/pacticipants/delivery-service/versions/${env.VERSION}/tags/${env.STAGE}"
sh "curl -X DELETE http://pact-service:8080/pacticipants/delivery-service/versions/${env.VERSION}/tags/pending-${env.STAGE}"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions delivery-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<pactBroker.url>http://localhost:5000</pactBroker.url>
<pact.tag>develop</pact.tag>
<meecrowave.version>1.2.13</meecrowave.version>
<deltaspike.version>1.9.6</deltaspike.version>
<hibernate.version>5.4.21.Final</hibernate.version>
Expand Down Expand Up @@ -199,6 +200,7 @@
<configuration>
<systemPropertyVariables>
<pact.provider.version>${project.version}</pact.provider.version>
<pact.tag>${pact.tag}</pact.tag>
<pactBroker.url>${pactBroker.url}</pactBroker.url>
<javax.persistence.jdbc.url>jdbc:h2:mem:delivery</javax.persistence.jdbc.url>
<javax.persistence.jdbc.driver>org.h2.Driver</javax.persistence.jdbc.driver>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@
import au.com.dius.pact.provider.junitsupport.State;
import au.com.dius.pact.provider.junitsupport.StateChangeAction;
import au.com.dius.pact.provider.junitsupport.loader.PactBroker;
import au.com.dius.pact.provider.junitsupport.loader.VersionSelector;
import de.openknowledge.sample.address.domain.AddressValidationService;
import rocks.limburg.cdimock.MockitoBeans;

@IgnoreNoPactsToVerify
@MockitoBeans(types = {AddressValidationService.class})
@Provider("delivery-service")
@PactBroker(url = "${pactBroker.url:http://localhost:5000}")
@PactBroker(url = "${pactBroker.url:http://localhost:5000}", consumerVersionSelectors = @VersionSelector(tag = "${pact.tag}"))
@MonoMeecrowaveConfig
public class DeliveryAddressServiceTest {

Expand Down

0 comments on commit c732329

Please sign in to comment.