Skip to content

Commit 3f77e72

Browse files
authored
archive AQACert log in parent build (#3536)
- Since all AQACert.log are the same for the parent build, only archive one AQACert.log from a child build - Update archiveFile() logic to handle the case where we want to archive on both Jenkins and Artifactory. *.tap files and AQACert.log have to be archived on Jenkins in order for the parent job to pick up. - Add cleanWs before archiving child build files to avoid copying the wrong files - Update the logic to archive a specific TAP file for each child (instead of **/*.tap). This is to resolve #3539 - Add TODO for future enhancement Resolve: #3539 Signed-off-by: lanxia <[email protected]>
1 parent c43f759 commit 3f77e72

File tree

1 file changed

+50
-35
lines changed

1 file changed

+50
-35
lines changed

buildenv/jenkins/JenkinsfileBase

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -685,18 +685,13 @@ def post(output_name) {
685685

686686
step([$class: "TapPublisher", testResults: "**/*.tap", outputTapToConsole: false, failIfNoResults: true])
687687

688-
// only archive children TAP result in parallel mode, the file will be copied into the parent job after parallel runs
689-
if (params.UPSTREAM_TEST_JOB_NAME && params.UPSTREAM_TEST_JOB_NUMBER) {
690-
archiveArtifacts artifacts: "**/*.tap", fingerprint: true, allowEmptyArchive: true
691-
}
692-
693688
junit allowEmptyResults: true, keepLongStdio: true, testResults: '**/work/**/*.jtr.xml, **/junitreports/**/*.xml, **/external_test_reports/**/*.xml'
694689

695690
//call the archive function for each file
696-
archiveFile("aqa-tests/testenv/testenv.properties")
697-
archiveFile("aqa-tests/TKG/SHA.txt")
698-
archiveFile("aqa-tests/TKG/AQACert.log")
699-
archiveFile("**/*.tap")
691+
archiveFile("aqa-tests/testenv/testenv.properties", true)
692+
archiveFile("aqa-tests/TKG/SHA.txt", true)
693+
archiveFile("aqa-tests/TKG/AQACert.log", true)
694+
archiveFile("**/*.tap", true)
700695

701696
if (env.BUILD_LIST.startsWith('jck')) {
702697
xunit (
@@ -728,6 +723,7 @@ def post(output_name) {
728723
sh "${tar_cmd} ${test_output_tar_name} ${pax_opt} ./aqa-tests/TKG/output_* ${tar_cmd_suffix}"
729724
}
730725

726+
// TODO: archiveFile() should be used
731727
if (!params.ARTIFACTORY_SERVER) {
732728
echo "ARTIFACTORY_SERVER is not set. Saving artifacts on jenkins."
733729
archiveArtifacts artifacts: test_output_tar_name, fingerprint: true, allowEmptyArchive: true
@@ -892,11 +888,14 @@ def getJenkinsDomain() {
892888
return domainName
893889
}
894890

895-
def archiveFile(filename){
896-
if(!params.ARTIFACTORY_SERVER){
897-
echo "ARTIFACTORY_SERVER is not set. Saving ${filename} file on jenkins."
891+
// If forceStoreOnJenkins set to true, archive on Jenkins.
892+
// If forceStoreOnJenkins set to false, archive on Artifactory if ARTIFACTORY_SERVER is provided. Otherwise, archive on Jenkins
893+
def archiveFile(filename, forceStoreOnJenkins) {
894+
if (!params.ARTIFACTORY_SERVER || forceStoreOnJenkins) {
895+
echo "Saving ${filename} file on jenkins."
898896
archiveArtifacts artifacts: filename, fingerprint: true, allowEmptyArchive: true
899-
} else {
897+
}
898+
if (params.ARTIFACTORY_SERVER) {
900899
def pattern = "${env.WORKSPACE}/${filename}"
901900
uploadToArtifactory(pattern)
902901
}
@@ -1003,30 +1002,46 @@ def run_parallel_tests() {
10031002
stage ("Parallel Tests") {
10041003
def childJobs = parallel parallel_tests
10051004
node {
1006-
def buildResult = ""
1007-
childJobs.each {
1008-
cjob ->
1009-
def jobInvocation = cjob.value.getRawBuild()
1010-
def buildId = jobInvocation.getNumber()
1011-
def name = cjob.value.getProjectName()
1012-
def childResult = cjob.value.getCurrentResult()
1013-
try {
1014-
echo "${name} #${buildId} completed with status ${childResult}"
1015-
timeout(time: 1, unit: 'HOURS') {
1016-
copyArtifacts (projectName: "${name}", selector: specific("${buildId}"), filter: "**/*.tap", target:"${name}/${buildId}")
1005+
// cleanWs() does not work in some cases, so set opts below
1006+
cleanWs disableDeferredWipeout: true, deleteDirs: true
1007+
try {
1008+
def buildResult = ""
1009+
// for parallel run, only archive AQACert log once in the parent build
1010+
def archiveAQACert = false
1011+
childJobs.each {
1012+
cjob ->
1013+
def jobInvocation = cjob.value.getRawBuild()
1014+
def buildId = jobInvocation.getNumber()
1015+
def name = cjob.value.getProjectName()
1016+
def childResult = cjob.value.getCurrentResult()
1017+
try {
1018+
echo "${name} #${buildId} completed with status ${childResult}"
1019+
timeout(time: 1, unit: 'HOURS') {
1020+
copyArtifacts (projectName: "${name}", selector: specific("${buildId}"), filter: "**/*.tap", target:"${name}/${buildId}")
1021+
if (!archiveAQACert) {
1022+
copyArtifacts (projectName: "${name}", selector: specific("${buildId}"), filter: "**/AQACert.log", target:"${name}/${buildId}")
1023+
}
1024+
}
1025+
step([$class: "TapPublisher", testResults: "${name}/${buildId}/**/*.tap", outputTapToConsole: false, failIfNoResults: true])
1026+
archiveFile("${name}/${buildId}/**/*.tap", true)
1027+
if (!archiveAQACert) {
1028+
archiveFile("${name}/${buildId}/**/AQACert.log", true)
1029+
archiveAQACert = true
1030+
}
1031+
} catch (Exception e) {
1032+
echo "Cannot copy *.tap or AQACert.log from ${name} with buildid ${buildId} . Skipping copyArtifacts..."
1033+
buildResult = childResult
10171034
}
1018-
step([$class: "TapPublisher", testResults: "${name}/${buildId}/**/*.tap", outputTapToConsole: false, failIfNoResults: true])
1019-
} catch (Exception e) {
1020-
echo "Cannot copy *.tap from ${name} with buildid ${buildId} . Skipping copyArtifacts..."
1021-
buildResult = childResult
1022-
}
1023-
}
1024-
if (buildResult) {
1025-
echo "set build status to ${buildResult}"
1026-
currentBuild.result = buildResult
1035+
}
1036+
if (buildResult) {
1037+
echo "set build status to ${buildResult}"
1038+
currentBuild.result = buildResult
1039+
}
1040+
addFailedTestsGrinderLink()
1041+
} finally {
1042+
// cleanWs() does not work in some cases, so set opts below
1043+
cleanWs disableDeferredWipeout: true, deleteDirs: true
10271044
}
1028-
archiveFile("**/*.tap")
1029-
addFailedTestsGrinderLink()
10301045
}
10311046
}
10321047
}

0 commit comments

Comments
 (0)