Peter Kahn
Peter Kahn

Reputation: 13026

Combining ArtifactArchiver and JunitResultsArchiver from different nodes using jenkins workflow

How do I archive content from multiple nodes in a parallel build process?

I have a jenkins workflow job which builds win/lin in parallel. When the job finishes, linux results overwirte the windows results.

How do I share or collect results from each node so I get both sets in my final product?

def branches = [:]

branches["Windows Build"] = {
  node('winx64&&slave')
  {
    // Do build
    ...
    // Collect      
    step([$class: 'JUnitResultArchiver', testResults: '**/build/test-results/*.xml', fingerprint: false])
    step([$class: 'ArtifactArchiver', artifacts: '**/build/reports/**,**/build/*.log', excludes: null])      }                
  }
}

branches["LinuxBuild"] = {
  node('linx64&&slave')
  {
    // Do build
    ...
    // Collect      
    step([$class: 'JUnitResultArchiver', testResults: '**/build/test-results/*.xml', fingerprint: false])
    step([$class: 'ArtifactArchiver', artifacts: '**/build/reports/**,**/build/*.log', excludes: null])      }                
  }
  }
}

Upvotes: 1

Views: 1059

Answers (2)

amuniz
amuniz

Reputation: 3342

You can use stash/unstash steps with different names to retrieve the reports later and do whatever you want with them.

parallel firstBranch: {
    // do something
    stash includes: '**/build/reports/**,**/build/*.log', name: 'first'
}, secondBranch: {
    // do something else
    stash includes: '**/build/reports/**,**/build/*.log', name: 'second'
}

dir('dir1') {
    unstash 'first'
    // do whatever you want
}
archive 'dir1/*'

dir('dir2') {
    unstash 'second'
    // do whatever you want
}
archive 'dir2/*'

Upvotes: 2

Peter Kahn
Peter Kahn

Reputation: 13026

FYI, I guess I could do the work in a Lin and Win directory and archive results from Win//... and Lin//... that's combine them and not overwrite but it seems a little kludgy.

Upvotes: 0

Related Questions