Pipeline - How to combine wrappers in Pipeline jobs

Issue

How do I put two wrappers together in a Pipeline job?

Environment

  • CloudBees Jenkins Enterprise
  • Pipeline
  • Linux node/agent

Resolution

You can nest them.

Example:

node {
    wrap([$class: 'BuildUser']) { // https://wiki.jenkins-ci.org/display/JENKINS/Build+User+Vars+Plugin
        wrap([$class: 'TimestamperBuildWrapper']) { // https://wiki.jenkins-ci.org/display/JENKINS/Timestamper
            sh 'echo ${BUILD_USER}' // both wrappers applied here
        }
    }
}

Reference

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.