Hey,

Here is my pipeline landscape:

Master pipeline is triggering smaller child pipelines.

Parent pipeline script snippet:

stage('Integration Tests') {
    steps {
        script {
            def jobs = [:]
            pipelineIntegrationJobs.each {
                i ->
                    jobs["${nirvanaMajor}.${nirvanaMinor}_${i}"] = {
                        def buildInstance = build(job: 
"${nirvanaMajor}.${nirvanaMinor}_${i}",
                                parameters: [
                                        string(name: 'branch', value: 
"${svnBranch}", description: 'svn repository url'),
                                        string(name: 'buildmajor', value: 
'10', description: 'release major identifier'),
                                        string(name: 'buildminor', value: 
'4', description: 'release minor identifier'),
                                        string(name: 'fix', value: 
"${env.fix}", description: 'fix level'),
                                        string(name: 'buildnumber', value: 
"${env.buildNumber}", description: 'artifacts build number'),
                                        string(name: 'revision', value: 
"${env.buildNumber}", description: 'checkout revision'),
                                        string(name: 'joblabel', value: 
"${pipelineName}", description: "optional job description")
                                ], quietPeriod: 0, propagate: false, wait: 
true)
                        def downstreamJobName = 
"${masterUrl}/job/${nirvanaMajor}.${nirvanaMinor}_${i}/" + 
buildInstance.number
                        jobStateResults.put(downstreamJobName, 
buildInstance.result)
                    }
            }
            parallel jobs
        }
    }
}


The child pipeline script uses this method below [getTestResults()] to 
extract the build test results and it works perfect.

I would like to push this data up to the master pipeline so that I collect 
all child jobs results.
 
I see the return type of build(job: "child_job") is a RunWrapper (
https://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html)
 
but how do I extract AbstractTestResultAction from it?


Child pipeline script snippet:
import hudson.tasks.test.AbstractTestResultAction

@NonCPS
def getTestResults () {
def results = [:]
AbstractTestResultAction testResultAction = 
currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
if (testResultAction != null) {
def total = testResultAction.getTotalCount()
def failed = testResultAction.getFailCount()
def skipped = testResultAction.getSkipCount()
def passed = total - failed - skipped
results.put ("Total", total)
results.put ("Passed", passed)
results.put ("Failed", failed)
results.put ("Skipped", skipped)

if (failed == 0) {
currentBuild.result = 'SUCCESS'
}
echo "------------------------------------"
echo "Test Results Summary:"
results.each{ k, v -> echo "${k}: ${v}" }
echo "------------------------------------"
} else {
echo 'No tests results'
}
return results
}

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/1a65a9dc-b093-4ed8-9fd0-de433757c202%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to