|
14 | 14 | * and limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
| 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 | + |
17 | 46 | stage('Build') { |
18 | 47 | // Checkout, build and assemble the source and doc |
19 | 48 | node { |
20 | 49 | 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 |
26 | 55 | ]) |
27 | 56 | sh './gradlew clean assemble' |
28 | 57 | stash name: 'built' |
29 | 58 | } |
30 | 59 | } |
31 | 60 |
|
32 | 61 | 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 |
46 | 74 | 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' |
48 | 76 | } finally { |
49 | | - junit '**/build/test-results/*.xml' |
| 77 | + step([$class: 'FindBugsPublisher', pattern: '**/build/reports/findbugs/*.xml']) |
50 | 78 | } |
51 | 79 | } |
| 80 | + }, |
| 81 | + Java_Cloudant : { |
| 82 | + runTests(CLOUDANT_ENV, false) |
| 83 | + }, |
| 84 | + Android_Cloudant: { |
| 85 | + runTests(CLOUDANT_ENV, true) |
52 | 86 | } |
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) |
67 | 109 | } |
68 | | - } |
69 | | - } |
70 | | - ) |
| 110 | + ) |
| 111 | + } |
| 112 | + |
| 113 | + // Run the required axes in parallel |
| 114 | + parallel(axes) |
71 | 115 | } |
72 | 116 |
|
73 | 117 | // Publish the master branch |
|
0 commit comments