Environment variables are not available in pre precieve hook
Summary
We are deployed GitLab server from official helm chart.
For validating commit messages we are use bash-script in /home/git/custom_hooks/pre-receive.d/
directory. After update to version 13.7.4-ee (368b4fb2eee)
variables described in administration docs is not available.
Steps to reproduce
- Script source:
git@server-gitaly-0:~$ cat /home/git/custom_hooks/pre-receive.d/youtrack-id-hook.sh
#!/usr/bin/env bash
env > /tmp/pre-receive-hook.env
echo "$GL_PROJECT_PATH" > /tmp/gl-project-path
-
Commit and push any changes to repository.
-
View debug info:
git@server-gitaly-0:~$ cat /tmp/gl-project-path
git@server-gitaly-0:~$ cat /tmp/pre-receive-hook.env
GIT_CONFIG_PARAMETERS='core.alternateRefsCommand=exit 0 #' 'receive.fsck.badTimezone=ignore' 'uploadpack.allowFilter=true' 'uploadpack.allowAnySHA1InWant=true' 'core.hooksPath=/srv/gitaly-ruby/git-hooks'
CORRELATION_ID=01EWJFPCSZAMWQG6B3TRMZVC9R
GIT_DIR=.
PWD=/home/git/repositories/@hashed/04/a8/04a8708c3a481ced13845a30de522486895de0592222c29326d9139ec2b9df25.git
GIT_QUARANTINE_PATH=/home/git/repositories/@hashed/04/a8/04a8708c3a481ced13845a30de522486895de0592222c29326d9139ec2b9df25.git/./objects/incoming-t1QnUM
GIT_OBJECT_DIRECTORY=/home/git/repositories/@hashed/04/a8/04a8708c3a481ced13845a30de522486895de0592222c29326d9139ec2b9df25.git/./objects/incoming-t1QnUM
GIT_EXEC_PATH=/usr/local/libexec/git-core
HOME=/home/git
LANG=en_US.UTF-8
GITALY_HOOKS_PAYLOAD=eyJiaW5hc...omited...
GITALY_LOG_DIR=/var/log/gitaly
GITALY_BIN_DIR=/usr/local/bin
GIT_PUSH_OPTION_COUNT=0
SHLVL=1
GIT_ALTERNATE_OBJECT_DIRECTORIES=/home/git/repositories/@hashed/04/a8/04a8708c3a481ced13845a30de522486895de0592222c29326d9139ec2b9df25.git/./objects
PATH=/usr/local/libexec/git-core:/usr/local/libexec/git-core:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GIT_TERMINAL_PROMPT=0
_=/usr/bin/env
Example Project
None
What is the current bug behavior?
Script environment contains no GL_*
variables.
What is the expected correct behavior?
Environment variables must be set when script executed:
GL_ID
GL_PROJECT_PATH
GL_PROTOCOL
GL_REPOSITORY
GL_USERNAME
Relevant logs and/or screenshots
Gitaly log:
{"correlation_id":"01EWJFPCSZAMWQG6B3TRMZVC9R","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.deadline_type":"none","grpc.method":"UpdateHook","grpc.request.fullMethod":"/gitaly.HookService/UpdateHook","grpc.request.glProjectPath":"agisoft-cloud/frontend/cloud-frontend","grpc.request.glRepository":"project-351","grpc.request.repoPath":"@hashed/04/a8/04a8708c3a481ced13845a30de522486895de0592222c29326d9139ec2b9df25.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"@hashed","grpc.service":"gitaly.HookService","grpc.start_time":"2021-01-21T12:46:18Z","grpc.time_ms":0.364,"level":"info","msg":"finished streaming call with code OK","peer.address":"@","pid":11,"span.kind":"server","system":"grpc","time":"2021-01-21T12:46:18.787Z"}
{"correlation_id":"01EWJFPCSZAMWQG6B3TRMZVC9R","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.deadline_type":"none","grpc.method":"ReferenceTransactionHook","grpc.request.fullMethod":"/gitaly.HookService/ReferenceTransactionHook","grpc.request.glProjectPath":"agisoft-cloud/frontend/cloud-frontend","grpc.request.glRepository":"project-351","grpc.request.repoPath":"@hashed/04/a8/04a8708c3a481ced13845a30de522486895de0592222c29326d9139ec2b9df25.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"@hashed","grpc.service":"gitaly.HookService","grpc.start_time":"2021-01-21T12:46:18Z","grpc.time_ms":0.251,"level":"info","msg":"finished streaming call with code OK","peer.address":"@","pid":11,"span.kind":"server","system":"grpc","time":"2021-01-21T12:46:18.801Z"}
{"correlation_id":"01EWJFPCSZAMWQG6B3TRMZVC9R","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.deadline_type":"none","grpc.method":"ReferenceTransactionHook","grpc.request.fullMethod":"/gitaly.HookService/ReferenceTransactionHook","grpc.request.glProjectPath":"agisoft-cloud/frontend/cloud-frontend","grpc.request.glRepository":"project-351","grpc.request.repoPath":"@hashed/04/a8/04a8708c3a481ced13845a30de522486895de0592222c29326d9139ec2b9df25.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"@hashed","grpc.service":"gitaly.HookService","grpc.start_time":"2021-01-21T12:46:18Z","grpc.time_ms":0.274,"level":"info","msg":"finished streaming call with code OK","peer.address":"@","pid":11,"span.kind":"server","system":"grpc","time":"2021-01-21T12:46:18.815Z"}
{"content_length_bytes":230,"correlation_id":"01EWJFPCSZAMWQG6B3TRMZVC9R","duration_ms":74,"level":"info","method":"POST","msg":"Finished HTTP request","status":200,"time":"2021-01-21T12:46:18.903Z","url":"http://server-webservice-default.gitlab.svc:8181//api/v4/internal/post_receive"}
{"correlation_id":"01EWJFPCSZAMWQG6B3TRMZVC9R","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.deadline_type":"none","grpc.method":"PostReceiveHook","grpc.request.fullMethod":"/gitaly.HookService/PostReceiveHook","grpc.request.glProjectPath":"agisoft-cloud/frontend/cloud-frontend","grpc.request.glRepository":"project-351","grpc.request.repoPath":"@hashed/04/a8/04a8708c3a481ced13845a30de522486895de0592222c29326d9139ec2b9df25.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"@hashed","grpc.service":"gitaly.HookService","grpc.start_time":"2021-01-21T12:46:18Z","grpc.time_ms":75.411,"level":"info","msg":"finished streaming call with code OK","peer.address":"@","pid":11,"span.kind":"server","system":"grpc","time":"2021-01-21T12:46:18.903Z"}
{"correlation_id":"01EWJFPCSZAMWQG6B3TRMZVC9R","diskcache":"e49d20fe-d52e-4cd4-9116-41c899177373","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-shell","grpc.meta.deadline_type":"none","grpc.method":"SSHReceivePack","grpc.request.fullMethod":"/gitaly.SSHService/SSHReceivePack","grpc.request.glProjectPath":"agisoft-cloud/frontend/cloud-frontend","grpc.request.glRepository":"project-351","grpc.request.repoPath":"@hashed/04/a8/04a8708c3a481ced13845a30de522486895de0592222c29326d9139ec2b9df25.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"@hashed","grpc.service":"gitaly.SSHService","grpc.start_time":"2021-01-21T12:46:18Z","level":"info","msg":"diskcache state change","peer.address":"10.233.81.102:37320","pid":11,"remote_ip":"10.233.99.0","span.kind":"server","system":"grpc","time":"2021-01-21T12:46:18.910Z","user_id":"user-32","username":"...omited..."}
{"correlation_id":"01EWJFPCSZAMWQG6B3TRMZVC9R","grpc.code":"OK","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-shell","grpc.meta.deadline_type":"none","grpc.method":"SSHReceivePack","grpc.request.fullMethod":"/gitaly.SSHService/SSHReceivePack","grpc.request.glProjectPath":"agisoft-cloud/frontend/cloud-frontend","grpc.request.glRepository":"project-351","grpc.request.repoPath":"@hashed/04/a8/04a8708c3a481ced13845a30de522486895de0592222c29326d9139ec2b9df25.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"@hashed","grpc.service":"gitaly.SSHService","grpc.start_time":"2021-01-21T12:46:18Z","grpc.time_ms":380.73,"level":"info","msg":"finished streaming call with code OK","peer.address":"10.233.81.102:37320","pid":11,"remote_ip":"10.233.99.0","span.kind":"server","system":"grpc","time":"2021-01-21T12:46:18.911Z","user_id":"user-32","username":"...omitted..."}
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)