79592606

Date: 2025-04-25 13:23:12
Score: 0.5
Natty:
Report link

This works for replayed (not rebuilt builds) builds. The output is the build number of the original build from which your current build was replayed from:

def getReplayCauseNumber() {
    // This function is used to access the build number of the build from which a build was replayed from

    def cause = currentBuild.rawBuild.getCause(org.jenkinsci.plugins.workflow.cps.replay.ReplayCause)

    if (cause == null){
        return null
    }
    
    def originalNum = cause.getOriginalNumber()
    echo "This build was replayed from build #${originalNum}"
    return originalNum
    
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Xilef Blaytra