Environment Variables not available from Web UI #2424

Closed
opened 2025-11-02 04:35:42 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @Etzelia on GitHub (Oct 19, 2018).

  • Gitea version (or commit ref): 1.6.0-rc1
  • Git version: 2.7.4
  • Operating system: Ubuntu 16.04
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant (possibly relevant? I can if you really need me to, but my server is fairly fresh so it shouldn't be any hacks/custom settings)
  • Log gist:

Description

When running actions on the web UI, it seems as though the special Gitea environment variables are not being exported for use in the shell (the git hooks, for example).
Things I tried include:

  • Committing right from the Gitea web UI
  • Creating a PR (this still kicks off post-receive)
  • Merging the above PR (or any other PR)

When I included a printenv statement in the hook to check what variables were available, I was given this output when using the above scenarios.

From Web UI

GIT_DIR=.
SHELL=/bin/bash
GITEA_WORK_DIR=/var/lib/gitea
USER=git
PATH=/usr/lib/git-core:/usr/lib/git-core:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/home/git/gitea-repositories/etzelia/test.git
LANG=enUS.UTF-8
HOME=/home/git
SHLVL=2
LOGNAME=git
=/usr/bin/printenv


Using that same hook, this is the output given when pushing from local -> remote
SSH

XDG_SESSION_ID=1052
GIT_DIR=.
SHELL=/bin/bash
GITEA_REPO_ID=41
SSH_CLIENT=[I removed IP information]
GITEA_PUSHER_ID=1
USER=git
GITEA_REPO_IS_WIKI=false
MAIL=/var/mail/git
PATH=/usr/lib/git-core:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
_=/usr/bin/printenv
PWD=/home/git/gitea-repositories/etzelia/test.git
LANG=en_US.UTF-8
SHLVL=3
HOME=/home/git
SSH_ORIGINAL_COMMAND=git-receive-pack 'Etzelia/test.git'
GITEA_PUSHER_NAME=Etzelia
LOGNAME=git
SSH_CONNECTION=[I removed IP information]
GITEA_REPO_NAME=test
XDG_RUNTIME_DIR=/run/user/112
GITEA_REPO_USER_NAME=etzelia

HTTPS

GIT_DIR=.
SHELL=/bin/bash
GITEA_REPO_ID=41
GITEA_WORK_DIR=/var/lib/gitea
GITEA_PUSHER_ID=1
USER=git
GITEA_REPO_IS_WIKI=false
PATH=/usr/lib/git-core:/usr/lib/git-core:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/bin/printenv
PWD=/home/git/gitea-repositories/etzelia/test.git
LANG=en_US.UTF-8
HOME=/home/git
GITEA_PUSHER_EMAIL=etzelia@hotmail.com
SHLVL=2
GITEA_PUSHER_NAME=Etzelia
SSH_ORIGINAL_COMMAND=receive-pack
LOGNAME=git
GITEA_REPO_NAME=test
GITEA_REPO_USER_NAME=Etzelia

Screenshots

This involved the Web UI, however it is a internal issue, not external.

Originally created by @Etzelia on GitHub (Oct 19, 2018). <!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.6.0-rc1 - Git version: 2.7.4 - Operating system: Ubuntu 16.04 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant (possibly relevant? I can if you really need me to, but my server is fairly fresh so it shouldn't be any hacks/custom settings) - Log gist: ## Description When running actions on the web UI, it seems as though the special Gitea environment variables are not being exported for use in the shell (the git hooks, for example). Things I tried include: * Committing right from the Gitea web UI * Creating a PR (this still kicks off post-receive) * Merging the above PR (or any other PR) When I included a `printenv` statement in the hook to check what variables were available, I was given this output when using the above scenarios. <details><summary>From Web UI</summary> <p> ``` GIT_DIR=. SHELL=/bin/bash GITEA_WORK_DIR=/var/lib/gitea USER=git PATH=/usr/lib/git-core:/usr/lib/git-core:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PWD=/home/git/gitea-repositories/etzelia/test.git LANG=enUS.UTF-8 HOME=/home/git SHLVL=2 LOGNAME=git =/usr/bin/printenv ``` </p> </details> <br> Using that same hook, this is the output given when pushing from local -> remote <details><summary>SSH</summary> <p> ``` XDG_SESSION_ID=1052 GIT_DIR=. SHELL=/bin/bash GITEA_REPO_ID=41 SSH_CLIENT=[I removed IP information] GITEA_PUSHER_ID=1 USER=git GITEA_REPO_IS_WIKI=false MAIL=/var/mail/git PATH=/usr/lib/git-core:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games _=/usr/bin/printenv PWD=/home/git/gitea-repositories/etzelia/test.git LANG=en_US.UTF-8 SHLVL=3 HOME=/home/git SSH_ORIGINAL_COMMAND=git-receive-pack 'Etzelia/test.git' GITEA_PUSHER_NAME=Etzelia LOGNAME=git SSH_CONNECTION=[I removed IP information] GITEA_REPO_NAME=test XDG_RUNTIME_DIR=/run/user/112 GITEA_REPO_USER_NAME=etzelia ``` </p> </details> <details><summary>HTTPS</summary> <p> ``` GIT_DIR=. SHELL=/bin/bash GITEA_REPO_ID=41 GITEA_WORK_DIR=/var/lib/gitea GITEA_PUSHER_ID=1 USER=git GITEA_REPO_IS_WIKI=false PATH=/usr/lib/git-core:/usr/lib/git-core:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin _=/usr/bin/printenv PWD=/home/git/gitea-repositories/etzelia/test.git LANG=en_US.UTF-8 HOME=/home/git GITEA_PUSHER_EMAIL=etzelia@hotmail.com SHLVL=2 GITEA_PUSHER_NAME=Etzelia SSH_ORIGINAL_COMMAND=receive-pack LOGNAME=git GITEA_REPO_NAME=test GITEA_REPO_USER_NAME=Etzelia ``` </p> </details> ## Screenshots This involved the Web UI, however it is a internal issue, not external. <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the issue/stale label 2025-11-02 04:35:42 -06:00
Author
Owner

@stale[bot] commented on GitHub (Jan 6, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 6, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@stale[bot] commented on GitHub (Feb 23, 2019):

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale[bot] commented on GitHub (Feb 23, 2019): This issue has been automatically closed because of inactivity. You can re-open it if needed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2424