Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 8a3c867

Browse files
authored
Merge pull request #517 from cloudant/jenkinsfile-matrix
Moved matrix testing into Jenkinsfile
2 parents 69a037a + f05d246 commit 8a3c867

File tree

1 file changed

+81
-37
lines changed

1 file changed

+81
-37
lines changed

Jenkinsfile

Lines changed: 81 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,104 @@
1414
* and limitations under the License.
1515
*/
1616

17+
def runTests(testEnv, isAndroid) {
18+
node(isAndroid ? 'android' : null) {
19+
if (isAndroid) {
20+
// Android tests run on static hardware so clean the dir
21+
deleteDir()
22+
testEnv.add('GRADLE_TARGET=-b AndroidTest/build.gradle uploadFixtures connectedCheck')
23+
} else {
24+
testEnv.add('GRADLE_TARGET=integrationTest')
25+
}
26+
// Unstash the built content
27+
unstash name: 'built'
28+
29+
//Set up the environment and run the tests
30+
withEnv(testEnv) {
31+
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: env.CREDS_ID, usernameVariable: 'DB_USER', passwordVariable: 'DB_PASSWORD']]) {
32+
try {
33+
sh './gradlew -Dtest.with.specified.couch=true -Dtest.couch.username=$DB_USER -Dtest.couch.password=$DB_PASSWORD -Dtest.couch.host=$DB_HOST -Dtest.couch.port=$DB_PORT -Dtest.couch.http=$DB_HTTP -Dtest.couch.ignore.compaction=$DB_IGNORE_COMPACTION -Dtest.couch.ignore.auth.headers=true $GRADLE_TARGET'
34+
} finally {
35+
junit '**/build/**/*.xml'
36+
if (isAndroid) {
37+
// Collect the device log
38+
archiveArtifacts artifacts: '**/build/**/*.log'
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
1746
stage('Build') {
1847
// Checkout, build and assemble the source and doc
1948
node {
2049
checkout([
21-
$class: 'GitSCM',
22-
branches: scm.branches,
23-
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
24-
extensions: scm.extensions + [[$class: 'CleanBeforeCheckout']],
25-
userRemoteConfigs: scm.userRemoteConfigs
50+
$class : 'GitSCM',
51+
branches : scm.branches,
52+
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
53+
extensions : scm.extensions + [[$class: 'CleanBeforeCheckout']],
54+
userRemoteConfigs : scm.userRemoteConfigs
2655
])
2756
sh './gradlew clean assemble'
2857
stash name: 'built'
2958
}
3059
}
3160

3261
stage('QA') {
33-
parallel(
34-
Java:
35-
{
36-
node {
37-
unstash name: 'built'
38-
// findBugs
39-
try {
40-
sh './gradlew -Dfindbugs.xml.report=true findbugsMain'
41-
} finally {
42-
step([$class: 'FindBugsPublisher', pattern: '**/build/reports/findbugs/*.xml'])
43-
}
44-
// tests
45-
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'clientlibs-test', usernameVariable: 'DB_USER', passwordVariable: 'DB_PASSWORD']]) {
62+
// Define the matrix environments
63+
def CLOUDANT_ENV = ['DB_HTTP=https', 'DB_HOST=clientlibs-test.cloudant.com', 'DB_PORT=443', 'DB_IGNORE_COMPACTION=true', 'CREDS_ID=clientlibs-test']
64+
def COUCH1_6_ENV = ['DB_HTTP=http', 'DB_HOST=cloudantsync002.bristol.uk.ibm.com', 'DB_PORT=5984', 'DB_IGNORE_COMPACTION=false', 'CREDS_ID=couchdb']
65+
def COUCH2_0_ENV = ['DB_HTTP=http', 'DB_HOST=cloudantsync002.bristol.uk.ibm.com', 'DB_PORT=5985', 'DB_IGNORE_COMPACTION=true', 'CREDS_ID=couchdb']
66+
def CLOUDANT_LOCAL_ENV = ['DB_HTTP=http', 'DB_HOST=cloudantsync002.bristol.uk.ibm.com', 'DB_PORT=8081', 'DB_IGNORE_COMPACTION=true', 'CREDS_ID=couchdb']
67+
68+
// Standard builds do Findbugs and test sync-android for Android and Java against Cloudant
69+
def axes = [
70+
Findbugs : {
71+
node {
72+
unstash name: 'built'
73+
// findBugs
4674
try {
47-
sh './gradlew -Dtest.with.specified.couch=true -Dtest.couch.username=$DB_USER -Dtest.couch.password=$DB_PASSWORD -Dtest.couch.host=clientlibs-test.cloudant.com -Dtest.couch.port=443 -Dtest.couch.http=https -Dtest.couch.ignore.compaction=true -Dtest.couch.ignore.auth.headers=true integrationTest'
75+
sh './gradlew -Dfindbugs.xml.report=true findbugsMain'
4876
} finally {
49-
junit '**/build/test-results/*.xml'
77+
step([$class: 'FindBugsPublisher', pattern: '**/build/reports/findbugs/*.xml'])
5078
}
5179
}
80+
},
81+
Java_Cloudant : {
82+
runTests(CLOUDANT_ENV, false)
83+
},
84+
Android_Cloudant: {
85+
runTests(CLOUDANT_ENV, true)
5286
}
53-
},
54-
Android:
55-
{
56-
node('android') {
57-
// Clean the directory before un-stashing
58-
deleteDir()
59-
unstash name: 'built'
60-
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'couchdb', usernameVariable: 'DB_USER', passwordVariable: 'DB_PASSWORD']]) {
61-
try {
62-
sh './gradlew -Dtest.with.specified.couch=true -Dtest.couch.username=$DB_USER -Dtest.couch.password=$DB_PASSWORD -Dtest.couch.host=cloudantsync002.bristol.uk.ibm.com -Dtest.couch.port=5984 -Dtest.couch.ignore.compaction=true -Dtest.couch.ignore.auth.headers=true -b AndroidTest/build.gradle uploadFixtures connectedCheck'
63-
} finally {
64-
junit '**/build/**/*.xml'
65-
archiveArtifacts artifacts: '**/build/**/*.log'
66-
}
87+
]
88+
// For the master branch, add additional axes to the coverage matrix for Couch 1.6, 2.0
89+
// and Cloudant Local
90+
if (env.BRANCH_NAME == "master") {
91+
axes.putAll(
92+
Java_Couch1_6: {
93+
runTests(COUCH1_6_ENV, false)
94+
},
95+
Android_Couch1_6: {
96+
runTests(COUCH1_6_ENV, true)
97+
},
98+
Java_Couch2_0: {
99+
runTests(COUCH2_0_ENV, false)
100+
},
101+
Android_Couch2_0: {
102+
runTests(COUCH2_0_ENV, true)
103+
},
104+
Java_CloudantLocal: {
105+
runTests(CLOUDANT_LOCAL_ENV, false)
106+
},
107+
Android_CloudantLocal: {
108+
runTests(CLOUDANT_LOCAL_ENV, true)
67109
}
68-
}
69-
}
70-
)
110+
)
111+
}
112+
113+
// Run the required axes in parallel
114+
parallel(axes)
71115
}
72116

73117
// Publish the master branch

0 commit comments

Comments
 (0)