diff --git a/Jenkinsfile b/Jenkinsfile index fd3fbb3d..2d7ff80f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,9 @@ def ptNameVersion = "admiral-${UUID.randomUUID().toString().toLowerCase()}" def jenkins_pod_label = "admiral-build" -def commitSha = '' +commitSha = '' + +envMap = [:] pipeline { @@ -29,6 +31,8 @@ pipeline { //from msaas generated service_name = "admiral" asset_id = "8287766806579881856" + heliograph_asset_id = "721719432597284573" + heliograph_application_name = "heliograph" application_name = "admiral" // *** update the Application Name you wish to use for metrics l1 = "services" @@ -54,10 +58,10 @@ pipeline { stage_timeout = 22 git_timeout = 2 pipelineStartTime = 0 - //envMap = [:] commit_id = "" git_tag = "" admiralTag = "placeholder" + heliographTag = "placeholder" serviceAssetId = "8287766806579881856" GIT_TOKEN = credentials('GIT_TOKEN') } @@ -65,6 +69,7 @@ pipeline { stage('pre-build-setup') { steps { script { + pipelineStartTime = System.currentTimeMillis() container('jnlp') { sh ''' apt-get update @@ -177,7 +182,9 @@ pipeline { iksType = "ppd" appName = "${l1}-${l2}-${service_name}-${region}-${iksType}" echo "Starting deploy" - deployGitOps('qal', appName, 'ppd') + iStage(appName, 'qal') { + deployGitOps('qal', appName, 'ppd') + } } } } @@ -269,7 +276,7 @@ def updateEnvTag(String env) { sh "git pull" - def heliographTag = readFile "heliograph-tag.txt" + heliographTag = readFile "heliograph-tag.txt" echo admiralTag echo heliographTag @@ -340,7 +347,10 @@ def _prepareAndSendMetrics(metricsType, startMillis, endMillis, envName, name, s if (metricsType == 'deployment') { _populateEnvMap(envName, endMillis) - _postToDataLake(_getDepIdxJSON(name, envName, status, startTime, endTime), metricsType) + //report admiral deployment to ODL + _postToDataLake(_getDepIdxJSON(name, envName, status, startTime, endTime, true), metricsType) + //report heliograph deployment to ODL + _postToDataLake(_getDepIdxJSON(name, envName, status, startTime, endTime, false), metricsType) _postToDataLake(_getStgIdxJSON("deploy $envName", status, startTime, endTime, totalTime), 'pipelinestage') } else if (metricsType == 'pipelinestage') { _postToDataLake(_getStgIdxJSON(name, status, startTime, endTime, totalTime), metricsType) @@ -349,18 +359,28 @@ def _prepareAndSendMetrics(metricsType, startMillis, endMillis, envName, name, s } } -def _getDepIdxJSON(appName, envName, status, startTime, endTime) { +def _getDepIdxJSON(appName, envName, status, startTime, endTime, admiral) { + def final_asset_id = asset_id + def final_app_name = application_name + def final_tag = admiralTag + def final_sha = commitSha + if (!admiral) { + final_asset_id = heliograph_asset_id + final_app_name = heliograph_application_name + final_tag = heliographTag + final_sha = heliographTag + } def metricsJson = """ { "deployTool" : "Jenkins Pipeline", "applicationName" : "${application_name}", - "applicationVersion" : "${git_tag}", - "commitId" : "${commit_id}", + "applicationVersion" : "${final_sha}", + "commitId" : "${final_tag}", "deployStartTime" : "${startTime}", - "assetId" : "${asset_id}", + "assetId" : "${final_asset_id}", "jobUrl" : "${env.BUILD_URL}", "clusterName" : "${argocd_server}", - "namespace" : "${appName}-${envName}", + "namespace" : "${final_app_name}-${envName}", "deployTarget": "AWS", "package": { "name": "ksonnet", @@ -381,7 +401,7 @@ def _getPLIdxJSON(status, startTime, endTime, totalTime) { "pipelineId" : "${ptNameVersion}", "pipelineName" : "${service_name}", "assetId" : "${asset_id}", - "commitId": "${commit_id}", + "commitId": "${commitSha}", "pipelineTool" : "Jenkins Pipeline", "applicationName" : "${application_name}", "target" : "AWS", @@ -403,7 +423,7 @@ def _getStgIdxJSON(stageName, status, startTime, endTime, totalTime) { "pipelineTool" : "Jenkins Pipeline", "stageType": "cd_stage", "assetId" : "${asset_id}", - "commitId": "${commit_id}", + "commitId": "${commitSha}", "applicationName" : "${application_name}", "target" : "AWS", "startTime" : "${startTime}",