Triggers 当使用Gerrit触发器插件时,哪些环境变量被传递给Jenkins?
我正在使用Gerrit触发器插件启动Jenkins构建,但还没有找到一个记录所有环境变量的好地方。这样的文档存在吗?首先,我让Jenkins build shell脚本转储所有环境变量,名称为Triggers 当使用Gerrit触发器插件时,哪些环境变量被传递给Jenkins?,triggers,jenkins,environment-variables,gerrit,Triggers,Jenkins,Environment Variables,Gerrit,我正在使用Gerrit触发器插件启动Jenkins构建,但还没有找到一个记录所有环境变量的好地方。这样的文档存在吗?首先,我让Jenkins build shell脚本转储所有环境变量,名称为GERRIT: GERRIT_PATCHSET_UPLOADER=\"Alan Thompson\" <theEmail@gmail.com> GERRIT_PATCHSET_REVISION=eec3b0b65fcdf30872befa2e9ace06e96cd487b4 GERRIT_CHA
GERRIT
:
GERRIT_PATCHSET_UPLOADER=\"Alan Thompson\" <theEmail@gmail.com>
GERRIT_PATCHSET_REVISION=eec3b0b65fcdf30872befa2e9ace06e96cd487b4
GERRIT_CHANGE_ID=Ieec3b0b65fcdf30872befa2e9ace06e96cd487b4
GERRIT_PATCHSET_NUMBER=1
GERRIT_EVENT_ACCOUNT_EMAIL=theEmail@gmail.com
GERRIT_CHANGE_NUMBER=8
GERRIT_CHANGE_OWNER=\"Alan Thompson\" <theEmail@gmail.com>
GERRIT_REFSPEC=refs/changes/08/8/1
GERRIT_EVENT_TYPE=change-merged
GERRIT_EVENT_ACCOUNT=\"Alan Thompson\" <theEmail@gmail.com>
GERRIT_CHANGE_SUBJECT=toast: this is great with coffee
GERRIT_CHANGE_OWNER_NAME=Alan Thompson
GERRIT_PROJECT=kitchen
GERRIT_EVENT_HASH=-1357519550
GERRIT_BRANCH=master
GERRIT_CHANGE_OWNER_EMAIL=theEmail@gmail.com
GERRIT_PATCHSET_UPLOADER_EMAIL=theEmail@gmail.com
GERRIT_CHANGE_URL=http://localhost/8
GERRIT_PATCHSET_UPLOADER_NAME=Alan Thompson
GERRIT_EVENT_ACCOUNT_NAME=Alan Thompson
GERRIT\u PATCHSET\u UPLOADER=\“Alan Thompson”
GERRIT_补丁集_修订版=EEC3B0B65FCDF30872EFA2E9ACE06E96CD487B4
GERRIT_CHANGE_ID=IEEC3B0B65FCDF30872EFA2E9ACE06E96CD487B4
GERRIT_补丁集_编号=1
GERRIT\u事件\u帐户\u电子邮件=theEmail@gmail.com
GERRIT_变更_编号=8
GERRIT\u CHANGE\u OWNER=\“艾伦·汤普森”
GERRIT_REFSPEC=参考/变更/08/8/1
GERRIT_事件_类型=合并更改
GERRIT\u事件\u账户=\“Alan Thompson\”
GERRIT_CHANGE_SUBJECT=吐司:这与咖啡搭配很好
GERRIT\u CHANGE\u OWNER\u NAME=Alan Thompson
GERRIT_项目=厨房
GERRIT_事件_散列=-1357519550
GERRIT_BRANCH=master
GERRIT\u变更\u所有者\u电子邮件=theEmail@gmail.com
GERRIT\u补丁集\u上传者\u电子邮件=theEmail@gmail.com
GERRIT\u更改\u URL=http://localhost/8
GERRIT_PATCHSET_UPLOADER_NAME=Alan Thompson
GERRIT\u EVENT\u ACCOUNT\u NAME=Alan Thompson
确切答案可以在源代码中找到,并且至少有一些源代码注释描述了它的含义。感谢您的分享。我在GitHub上找到了。我编写shell脚本来打印gerrit触发器变量
#!/bin/bash
# ============================================================
# Author: 凍仁翔 / chusiang.lai (at) gmail.com
# Blog: http://note.drx.tw
# Filename: showGerritTriggerVar.sh
# Description: show all variables of Gerrit Trigger.
# Last modified: 2014-08-28 14:40
# ===========================================================
echo -e "----
# Parameter name for the commit subject (commit message's 1st line).
\$GERRIT_CHANGE_SUBJECT = ${GERRIT_CHANGE_SUBJECT}
# Parameter name for the full commit message.
\$GERRIT_CHANGE_COMMIT_MESSAGE = ${GERRIT_CHANGE_COMMIT_MESSAGE}
# Parameter name for the branch.
\$GERRIT_BRANCH = ${GERRIT_BRANCH}
# Parameter name for the topic.
\$GERRIT_TOPIC = ${GERRIT_TOPIC}
# Parameter name for the change-id.
\$GERRIT_CHANGE_ID = ${GERRIT_CHANGE_ID}
# Parameter name for the change number.
\$GERRIT_CHANGE_NUMBER = ${GERRIT_CHANGE_NUMBER}
# Parameter name for the URL to the change.
\$GERRIT_CHANGE_URL = ${GERRIT_CHANGE_URL}
# Parameter name for the patch set number.
\$GERRIT_PATCHSET_NUMBER = ${GERRIT_PATCHSET_NUMBER}
# Parameter name for the patch set revision.
\$GERRIT_PATCHSET_REVISION = ${GERRIT_PATCHSET_REVISION}
# Parameter name for the Gerrit project name.
\$GERRIT_PROJECT = ${GERRIT_PROJECT}
# Parameter name for the refspec.
\$GERRIT_REFSPEC = ${GERRIT_REFSPEC}
# The name and email of the abandoner of the change.
\$GERRIT_CHANGE_ABANDONER = ${GERRIT_CHANGE_ABANDONER}
# The name of the abandoner of the change.
\$GERRIT_CHANGE_ABANDONER_NAME = ${GERRIT_CHANGE_ABANDONER_NAME}
# The email of the abandoner of the change.
\$GERRIT_CHANGE_ABANDONER_EMAIL = ${GERRIT_CHANGE_ABANDONER_EMAIL}
# The name and email of the owner of the change.
\$GERRIT_CHANGE_OWNER = ${GERRIT_CHANGE_OWNER}
# The name of the owner of the change.
\$GERRIT_CHANGE_OWNER_NAME = ${GERRIT_CHANGE_OWNER_NAME}
# The email of the owner of the change.
\$GERRIT_CHANGE_OWNER_EMAIL = ${GERRIT_CHANGE_OWNER_EMAIL}
# The name and email of the restorer of the change.
\$GERRIT_CHANGE_RESTORER = ${GERRIT_CHANGE_RESTORER}
# The name of the restorer of the change.
\$GERRIT_CHANGE_RESTORER_NAME = ${GERRIT_CHANGE_RESTORER_NAME}
# The email of the restorer of the change.
\$GERRIT_CHANGE_RESTORER_EMAIL = ${GERRIT_CHANGE_RESTORER_EMAIL}
# The name and email of the uploader of the patch-set.
\$GERRIT_PATCHSET_UPLOADER = ${GERRIT_PATCHSET_UPLOADER}
# The name of the uploader of the patch-set.
\$GERRIT_PATCHSET_UPLOADER_NAME = ${GERRIT_PATCHSET_UPLOADER_NAME}
# The email of the uploader of the patch-set.
\$GERRIT_PATCHSET_UPLOADER_EMAIL = ${GERRIT_PATCHSET_UPLOADER_EMAIL}
# The name and email of the person who triggered the event.
\$GERRIT_EVENT_ACCOUNT = ${GERRIT_EVENT_ACCOUNT}
# The name of the person who triggered the event.
\$GERRIT_EVENT_ACCOUNT_NAME = ${GERRIT_EVENT_ACCOUNT_NAME}
# The email of the person who triggered the event.
\$GERRIT_EVENT_ACCOUNT_EMAIL = ${GERRIT_EVENT_ACCOUNT_EMAIL}
# The refname in a ref-updated event.
\$GERRIT_REFNAME = ${GERRIT_REFNAME}
# The old revision in a ref-updated event.
\$GERRIT_OLDREV = ${GERRIT_OLDREV}
# The new revision in a ref-updated event.
\$GERRIT_NEWREV = ${GERRIT_NEWREV}
# The submitter in a ref-updated event.
\$GERRIT_SUBMITTER = ${GERRIT_SUBMITTER}
# The name of the submitter in a ref-updated event.
\$GERRIT_SUBMITTER_NAME = ${GERRIT_SUBMITTER_NAME}
# The email of the submitter in a ref-updated event.
\$GERRIT_SUBMITTER_EMAIL = ${GERRIT_SUBMITTER_EMAIL}
# The name of the Gerrit instance.
\$GERRIT_NAME = ${GERRIT_NAME}
# The host of the Gerrit instance.
\$GERRIT_HOST = ${GERRIT_HOST}
# The port number of the Gerrit instance.
\$GERRIT_PORT = ${GERRIT_PORT}
# The protocol scheme of the Gerrit instance.
\$GERRIT_SCHEME = ${GERRIT_SCHEME}
# The version of the Gerrit instance.
\$GERRIT_VERSION = ${GERRIT_VERSION}
# A hashcode of the Gerrit event object to make sure every set of parameters
# is unique (allowing jenkins to queue duplicate builds).
\$GERRIT_EVENT_HASH = ${GERRIT_EVENT_HASH}
# The type of the event.
\$GERRIT_EVENT_TYPE = ${GERRIT_EVENT_TYPE}
"
仅使用一行触发shell作业:
env | grep GERRIT_
并查看构建日志,它们列在触发器的帮助文本中;作业配置页面上“Gerrit事件”触发器复选框旁边的小问号
对于像我这样用头撞显示器的人来说,这是非常重要的信息。2016年5月,Jenkins进行了安全更新,不允许使用任意参数,除非在作业配置中定义了这些参数:
Alan Thompson定义的参数是正确的,但是您还需要在作业配置中定义这些参数。您使用了什么来获得输出?当我尝试列出Jenkins流程的所有环境变量时(从/proc/pid/environ)我不明白这些。@Alan可能只是一个简单的执行shell生成操作,它执行
env | grep'^GERRIT'
或类似操作。您的列表缺少GERRIT\u EVENT\u COMMENT\u TEXT
我可以找到一个显示所有可能的GERRIT触发器的帮助按钮,但没有一个显示所有可能的GERRIT环境变量的按钮。请发布一个正确的点击按钮的截图。我在上面的答案中添加了一个截图。这是“Gerrit事件”旁边的问号。