|
| 1 | +#!/bin/groovy |
| 2 | + |
| 3 | +library 'kibana-pipeline-library' |
| 4 | +kibanaLibrary.load() // load from the Jenkins instance |
| 5 | + |
| 6 | +stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a little bit |
| 7 | + timeout(time: 180, unit: 'MINUTES') { |
| 8 | + timestamps { |
| 9 | + ansiColor('xterm') { |
| 10 | + catchError { |
| 11 | + withEnv([ |
| 12 | + 'CODE_COVERAGE=1', // Needed for multiple ci scripts, such as remote.ts, test/scripts/*.sh, schema.js, etc. |
| 13 | + ]) { |
| 14 | + parallel([ |
| 15 | + 'kibana-intake-agent': { |
| 16 | + withEnv([ |
| 17 | + 'NODE_ENV=test' // Needed for jest tests only |
| 18 | + ]) { |
| 19 | + kibanaPipeline.legacyJobRunner('kibana-intake')() |
| 20 | + } |
| 21 | + }, |
| 22 | + 'x-pack-intake-agent': { |
| 23 | + withEnv([ |
| 24 | + 'NODE_ENV=test' // Needed for jest tests only |
| 25 | + ]) { |
| 26 | + kibanaPipeline.legacyJobRunner('x-pack-intake')() |
| 27 | + } |
| 28 | + }, |
| 29 | + 'kibana-oss-agent': kibanaPipeline.withWorkers('kibana-oss-tests', { kibanaPipeline.buildOss() }, [ |
| 30 | + 'oss-ciGroup1': kibanaPipeline.getOssCiGroupWorker(1), |
| 31 | + 'oss-ciGroup2': kibanaPipeline.getOssCiGroupWorker(2), |
| 32 | + 'oss-ciGroup3': kibanaPipeline.getOssCiGroupWorker(3), |
| 33 | + 'oss-ciGroup4': kibanaPipeline.getOssCiGroupWorker(4), |
| 34 | + 'oss-ciGroup5': kibanaPipeline.getOssCiGroupWorker(5), |
| 35 | + 'oss-ciGroup6': kibanaPipeline.getOssCiGroupWorker(6), |
| 36 | + 'oss-ciGroup7': kibanaPipeline.getOssCiGroupWorker(7), |
| 37 | + 'oss-ciGroup8': kibanaPipeline.getOssCiGroupWorker(8), |
| 38 | + 'oss-ciGroup9': kibanaPipeline.getOssCiGroupWorker(9), |
| 39 | + 'oss-ciGroup10': kibanaPipeline.getOssCiGroupWorker(10), |
| 40 | + 'oss-ciGroup11': kibanaPipeline.getOssCiGroupWorker(11), |
| 41 | + 'oss-ciGroup12': kibanaPipeline.getOssCiGroupWorker(12), |
| 42 | + ]), |
| 43 | + 'kibana-xpack-agent-1': kibanaPipeline.withWorkers('kibana-xpack-tests-1', { kibanaPipeline.buildXpack() }, [ |
| 44 | + 'xpack-ciGroup1': kibanaPipeline.getXpackCiGroupWorker(1), |
| 45 | + 'xpack-ciGroup2': kibanaPipeline.getXpackCiGroupWorker(2), |
| 46 | + ]), |
| 47 | + 'kibana-xpack-agent-2': kibanaPipeline.withWorkers('kibana-xpack-tests-2', { kibanaPipeline.buildXpack() }, [ |
| 48 | + 'xpack-ciGroup3': kibanaPipeline.getXpackCiGroupWorker(3), |
| 49 | + 'xpack-ciGroup4': kibanaPipeline.getXpackCiGroupWorker(4), |
| 50 | + ]), |
| 51 | + |
| 52 | + 'kibana-xpack-agent-3': kibanaPipeline.withWorkers('kibana-xpack-tests-3', { kibanaPipeline.buildXpack() }, [ |
| 53 | + 'xpack-ciGroup5': kibanaPipeline.getXpackCiGroupWorker(5), |
| 54 | + 'xpack-ciGroup6': kibanaPipeline.getXpackCiGroupWorker(6), |
| 55 | + 'xpack-ciGroup7': kibanaPipeline.getXpackCiGroupWorker(7), |
| 56 | + 'xpack-ciGroup8': kibanaPipeline.getXpackCiGroupWorker(8), |
| 57 | + 'xpack-ciGroup9': kibanaPipeline.getXpackCiGroupWorker(9), |
| 58 | + 'xpack-ciGroup10': kibanaPipeline.getXpackCiGroupWorker(10), |
| 59 | + ]), |
| 60 | + ]) |
| 61 | + kibanaPipeline.jobRunner('tests-l', false) { |
| 62 | + kibanaPipeline.downloadCoverageArtifacts() |
| 63 | + kibanaPipeline.bash( |
| 64 | + ''' |
| 65 | + # bootstrap from x-pack folder |
| 66 | + source src/dev/ci_setup/setup_env.sh |
| 67 | + cd x-pack |
| 68 | + yarn kbn bootstrap --prefer-offline |
| 69 | + cd .. |
| 70 | + # extract archives |
| 71 | + mkdir -p /tmp/extracted_coverage |
| 72 | + echo extracting intakes |
| 73 | + tar -xzf /tmp/downloaded_coverage/coverage/kibana-intake/kibana-coverage.tar.gz -C /tmp/extracted_coverage |
| 74 | + tar -xzf /tmp/downloaded_coverage/coverage/x-pack-intake/kibana-coverage.tar.gz -C /tmp/extracted_coverage |
| 75 | + echo extracting kibana-oss-tests |
| 76 | + tar -xzf /tmp/downloaded_coverage/coverage/kibana-oss-tests/kibana-coverage.tar.gz -C /tmp/extracted_coverage |
| 77 | + echo extracting kibana-xpack-tests |
| 78 | + for i in {1..3}; do |
| 79 | + tar -xzf /tmp/downloaded_coverage/coverage/kibana-xpack-tests-${i}/kibana-coverage.tar.gz -C /tmp/extracted_coverage |
| 80 | + done |
| 81 | + # replace path in json files to have valid html report |
| 82 | + pwd=$(pwd) |
| 83 | + du -sh /tmp/extracted_coverage/target/kibana-coverage/ |
| 84 | + echo replacing path in json files |
| 85 | + for i in {1..9}; do |
| 86 | + sed -i "s|/dev/shm/workspace/kibana|$pwd|g" /tmp/extracted_coverage/target/kibana-coverage/functional/${i}*.json & |
| 87 | + done |
| 88 | + wait |
| 89 | + # merge oss & x-pack reports |
| 90 | + echo merging coverage reports |
| 91 | + yarn nyc report --temp-dir /tmp/extracted_coverage/target/kibana-coverage/jest --report-dir target/kibana-coverage/jest-combined --reporter=html --reporter=json-summary |
| 92 | + yarn nyc report --temp-dir /tmp/extracted_coverage/target/kibana-coverage/functional --report-dir target/kibana-coverage/functional-combined --reporter=html --reporter=json-summary |
| 93 | + echo copy mocha reports |
| 94 | + mkdir -p target/kibana-coverage/mocha-combined |
| 95 | + cp -r /tmp/extracted_coverage/target/kibana-coverage/mocha target/kibana-coverage/mocha-combined |
| 96 | + ''', |
| 97 | + "run `yarn kbn bootstrap && merge coverage`" |
| 98 | + ) |
| 99 | + sh 'tar -czf kibana-jest-coverage.tar.gz target/kibana-coverage/jest-combined/*' |
| 100 | + kibanaPipeline.uploadCoverageArtifacts("coverage/jest-combined", 'kibana-jest-coverage.tar.gz') |
| 101 | + sh 'tar -czf kibana-functional-coverage.tar.gz target/kibana-coverage/functional-combined/*' |
| 102 | + kibanaPipeline.uploadCoverageArtifacts("coverage/functional-combined", 'kibana-functional-coverage.tar.gz') |
| 103 | + sh 'tar -czf kibana-mocha-coverage.tar.gz target/kibana-coverage/mocha-combined/*' |
| 104 | + kibanaPipeline.uploadCoverageArtifacts("coverage/mocha-combined", 'kibana-mocha-coverage.tar.gz') |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + kibanaPipeline.sendMail() |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | +} |
0 commit comments