@@ -13,7 +13,8 @@ it is need as field to store the results of the tests.
1313pipeline {
1414 agent any
1515 environment {
16- BASE_DIR = " src/github.com/elastic/apm-agent-nodejs"
16+ REPO = ' apm-agent-nodejs'
17+ BASE_DIR = " src/github.com/elastic/${ REPO} "
1718 PIPELINE_LOG_LEVEL = ' INFO'
1819 NOTIFY_TO = credentials(' notify-to' )
1920 JOB_GCS_BUCKET = credentials(' gcs-bucket' )
@@ -30,9 +31,9 @@ pipeline {
3031 quietPeriod(10 )
3132 }
3233 parameters {
33- string(name : ' NODE_VERSION' , defaultValue : " 11 " , description : " Node.js version to test" )
34+ string(name : ' NODE_VERSION' , defaultValue : " 12 " , description : " Node.js version to test" )
3435 string(name : ' BRANCH_SPECIFIER' , defaultValue : " master" , description : " Git branch/tag to use" )
35- string(name : ' CHANGE_TARGET ' , defaultValue : " master" , description : " Git branch/tag to merge before building" )
36+ string(name : ' MERGE_TARGET ' , defaultValue : " master" , description : " Git branch/tag to merge before building" )
3637 }
3738 stages {
3839 /**
@@ -47,7 +48,7 @@ pipeline {
4748 branch : " ${ params.BRANCH_SPECIFIER} " ,
4849 repo : " ${ REPO} " ,
4950 credentialsId : " ${ JOB_GIT_CREDENTIALS} " ,
50- mergeTarget : " ${ params.CHANGE_TARGET } "
51+ mergeTarget : " ${ params.MERGE_TARGET } " ,
5152 reference : ' /var/lib/jenkins/apm-agent-nodejs.git' )
5253 stash allowEmpty : true , name : ' source' , useDefaultExcludes : false
5354 }
@@ -82,29 +83,22 @@ pipeline {
8283 }
8384 }
8485 post {
85- always {
86+ cleanup {
8687 script{
8788 if (nodeTasksGen?. results){
8889 writeJSON(file : ' results.json' , json : toJSON(nodeTasksGen. results), pretty : 2 )
8990 def mapResults = [" ${ params.agent_integration_test} " : nodeTasksGen. results]
9091 def processor = new ResultsProcessor ()
9192 processor. processResults(mapResults)
9293 archiveArtifacts allowEmptyArchive : true , artifacts : ' results.json,results.html' , defaultExcludes : false
94+ catchError(buildResult : ' SUCCESS' ) {
95+ def datafile = readFile(file : " results.json" )
96+ def json = getVaultSecret(secret : ' secret/apm-team/ci/jenkins-stats-cloud' )
97+ sendDataToElasticsearch(es : json. data. url, data : datafile, restCall : ' /jenkins-builds-nodejs-test-results/_doc/' )
98+ }
9399 }
94100 }
95- }
96- success {
97- echoColor(text : ' [SUCCESS]' , colorfg : ' green' , colorbg : ' default' )
98- }
99- aborted {
100- echoColor(text : ' [ABORTED]' , colorfg : ' magenta' , colorbg : ' default' )
101- }
102- failure {
103- echoColor(text : ' [FAILURE]' , colorfg : ' red' , colorbg : ' default' )
104- step([$class : ' Mailer' , notifyEveryUnstableBuild : true , recipients : " ${ NOTIFY_TO} " , sendToIndividuals : false ])
105- }
106- unstable {
107- echoColor(text : ' [UNSTABLE]' , colorfg : ' yellow' , colorbg : ' default' )
101+ notifyBuildResult()
108102 }
109103 }
110104}
@@ -130,9 +124,9 @@ class NodeParallelTaskGenerator extends DefaultParallelTaskGenerator {
130124 saveResult(x, y, 1 )
131125 } catch (e){
132126 saveResult(x, y, 0 )
133- error(" ${ label} tests failed : ${ e.toString()} \n " )
127+ steps . error(" ${ label} tests failed : ${ e.toString()} \n " )
134128 } finally {
135- wrappingUp()
129+ steps . wrappingUp()
136130 }
137131 }
138132 }
@@ -158,9 +152,9 @@ def runScript(Map params = [:]){
158152 Collect test results and report to Codecov
159153*/
160154def wrappingUp (){
161- docker. image(' node:11 ' ). inside(" -v ${ WORKSPACE} /${ BASE_DIR} :/app" ){
162- steps . sh(label : " Convert Test results to JUnit format" , script : ' cd /app && .ci/convert_tap_to_junit.sh' )
155+ docker. image(' node:12 ' ). inside(" -v ${ WORKSPACE} /${ BASE_DIR} :/app" ){
156+ sh(label : " Convert Test results to JUnit format" , script : ' cd /app && .ci/scripts /convert_tap_to_junit.sh' )
163157 }
164158 junit(allowEmptyResults : true , keepLongStdio : true , testResults : " ${ BASE_DIR} /**/junit-*.xml" )
165- codecov(repo : ' apm-agent-nodejs ' , basedir : " ${ BASE_DIR} " , secret : " ${ CODECOV_SECRET} " )
159+ codecov(repo : env . REPO , basedir : " ${ BASE_DIR} " , secret : " ${ CODECOV_SECRET} " )
166160}
0 commit comments