如何知道哪个用户回答了Jenkins-Pipeline输入步骤? [英] How to know which user answered a Jenkins-Pipeline input step?
问题描述
我有一个Jenkinsfile脚本,用于测试执行SVN合并的可能性,然后向用户询问提交合并的权限.
I have a Jenkinsfile script that tests for the possibility to perform an SVN merge and then asks the user for the permission to commit the merge.
我想知道可以回答输入"步骤的用户名,以便将其写入提交消息中.
I would like to know the username that answers the "input" step in order to write it into the commit message.
这可能吗?
假设这是我想做的:
outcome = input message: 'Merge trunk into branch?', ok: 'Merge'
echo "User that allowed merge: ${outcome.user}"
推荐答案
The input
step got an optional submitterParameter
, which allows to specify the key of the returned Map
that should contain the user who's submitting the input dialog:
如果指定,则这是返回值的名称,该值将包含批准此输入的用户的ID.
返回值的处理方式类似于parameters
值.
类型:字符串
If specified, this is the name of the return value that will contain the ID of the user that approves this input.
The return value will be handled in a fashion similar to theparameters
value.
Type: String
然后看起来如下:
def feedback = input(submitterParameter: 'submitter', ...)
echo "It was ${feedback.submitter} who submitted the dialog."
PS:如果有人对完整的代码片段感兴趣,可以使用户同时获得对对话框的肯定和否定反馈(以及超时),那么请指向
P.S: If anybody is interested in a full-fledged code snippet returning the user both for positive and negative feedback to the dialog (and timeout as well), I kindly point to our pipeline library.
这篇关于如何知道哪个用户回答了Jenkins-Pipeline输入步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!