Какие переменные среды передаются Jenkins при использовании подключаемого модуля Gerrit Trigger?

Я использую подключаемый модуль Gerrit Trigger для запуска сборок Jenkins, но не нашел подходящего места, где документированы все переменные среды. Существует ли такая документация?


person Alan Thompson    schedule 16.05.2013    source источник


Ответы (6)


Для начала у меня был скрипт оболочки сборки Jenkins, выгружающий все переменные среды с GERRIT в имени:

GERRIT_PATCHSET_UPLOADER=\"Alan Thompson\" <[email protected]>
GERRIT_PATCHSET_REVISION=eec3b0b65fcdf30872befa2e9ace06e96cd487b4
GERRIT_CHANGE_ID=Ieec3b0b65fcdf30872befa2e9ace06e96cd487b4
GERRIT_PATCHSET_NUMBER=1
[email protected]
GERRIT_CHANGE_NUMBER=8
GERRIT_CHANGE_OWNER=\"Alan Thompson\" <[email protected]>
GERRIT_REFSPEC=refs/changes/08/8/1
GERRIT_EVENT_TYPE=change-merged
GERRIT_EVENT_ACCOUNT=\"Alan Thompson\" <[email protected]>
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
[email protected]
[email protected]
GERRIT_CHANGE_URL=http://localhost/8
GERRIT_PATCHSET_UPLOADER_NAME=Alan Thompson
GERRIT_EVENT_ACCOUNT_NAME=Alan Thompson
person Alan Thompson    schedule 16.05.2013
comment
Что вы использовали для получения результата? Когда я пытаюсь перечислить все переменные среды процесса Jenkins (из /proc/pid/environ), я их не получаю. - person TheMeaningfulEngineer; 15.07.2013
comment
@Alan Вероятно, это просто простая операция сборки оболочки, которая выполняет env | grep '^GERRIT' или что-то подобное. - person ffledgling; 08.08.2016

Точный ответ можно найти в источнике здесь, и есть по крайней мере некоторые комментарии к исходному коду, описывающие, что это значит.

person uncletall    schedule 16.05.2013

Спасибо за вашу долю. Я нашел GerritTriggerParameters.java на GitHub. и я пишу сценарий оболочки для вывода переменных gerrit-trigger.

#!/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}
"
person Chu-Siang Lai    schedule 28.08.2014
comment
Ваш список отсутствует GERRIT_EVENT_COMMENT_TEXT - person Jonathan Benn; 22.02.2019

Очень важная информация для тех, кто, как и я, бился головой о монитор. В мае 2016 года было выпущено обновление безопасности для Jenkins, которое не допускает произвольные параметры, если они не определены в конфигурации задания:

https://wiki.jenkins-ci.org/display/JENKINS/Plugins+affected+by+fix+for+SECURITY-170

Параметры, определенные Аланом Томпсоном, верны, но вам также необходимо определить эти параметры в конфигурации задания.

person Cristi Berceanu    schedule 21.07.2016

запустить задание оболочки всего одной строкой:

env | grep GERRIT_

и просмотрите журнал сборки

person smokku    schedule 13.11.2014

Они перечислены в тексте справки для триггера; маленький вопросительный знак рядом с флажком триггера события Gerrit на странице конфигурации задания.

введите здесь описание изображения

person Robert Sandell    schedule 24.04.2015
comment
Я могу найти кнопку справки, которая показывает все возможные триггеры Gerrit, но не ту, которая показывает все возможные переменные окружения Gerrit. Пожалуйста, опубликуйте скриншот правильной кнопки, на которую нужно нажать. - person Jonathan Benn; 13.08.2020
comment
Я добавил скриншот в ответ выше. Это знак вопроса рядом с событием Геррита. - person Bjorn; 19.03.2021