-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
Pipeline: Declarative - 1.7.2
The org.jenkinsci.plugins.pipeline.modeldefinition.causes.RestartDeclarativePipelineCause doesn't set @Exported visibility for the getOriginRunNumber and getOriginStage methods, so it is impossible to read values by using Jenkins declarative API: currentBuild.getBuildCauses().
pipeline { agent { label 'tiny' } stages { stage('One') { steps { echo 'one' } } stage('Two') { steps { echo 'two' script { currentBuild.getBuildCauses().each { echo "${it}" } } } } } }
Output when restarted from Stage:
[...] 12:02:38 [Pipeline] echo 12:02:38 [_class:hudson.model.Cause$UserIdCause, shortDescription:Started by user Gabrys, Adam, userId:SECRET, userName:Gabrys, Adam] 12:02:38 [Pipeline] echo 12:02:38 [_class:org.jenkinsci.plugins.pipeline.modeldefinition.causes.RestartDeclarativePipelineCause, shortDescription:Restarted from build #13, stage One] [...]
As you see Cause$UserIdCause exported all fields and RestartDeclarativePipelineCause only the short description (I don't want to parse string which btw. could be localized).