You could try this :
def owner = currentBuild.getBuildCauses(‘hudson.model.Cause$UserIDCause’)
manager.addShortText(“${Approval.userId[0]} ${Approval.userName}”)
Thanks,
On Tue, Aug 4, 2020 at 2:04 AM Gajanan Mahajan <[email protected]>
wrote:
> I have upstream and downstream pipelines and in downstream pipeline, I
> want to store user, who started upstream build, in downstream build
> variable.
>
> I used following in downstream pipeline but it results into error -
> `java.lang.NullPointerException: Cannot invoke method getUserId() on null
> object`
>
> Owner = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId()
>
> One way is to store it in a variable in upstream pipeline and pass it as
> param to downstream pipeline but that is additional handling and
> considering my parameters list, it is little tricky.
>
> Is there any way I can get user who started upstream build in downstream
> build without passing parameter?
>
> Similarly, `JOB_NAME` and `BUILD_NUMBER` of upstream to downstream.
>
> --
> 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/f4704e0d-5958-4075-bd00-e5666f2a127fo%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/f4704e0d-5958-4075-bd00-e5666f2a127fo%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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/CAPhsgOZzs_Yp2a3eHwQDmrySt9n7JqPoURJX_L3Fm2Zezsm9%3DQ%40mail.gmail.com.