concourse / pool-resource

atomically manages the state of the world (e.g. external environments)
Apache License 2.0
54 stars 36 forks source link

missing ability to customize git user and email #46

Closed bencao closed 2 years ago

bencao commented 5 years ago

Recently we encountered an issue that we're unable to claim a lock from git, by hijacking into the put container and manually run git push command, here's an output we got:

/tmp/pool-resource049555503 # git push origin master
Counting objects: 5, done.
Delta compression using up to 16 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 444 bytes | 222.00 KiB/s, done.
Total 5 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
remote: refs/heads/master cb32e210d3eadd2092bc271ec5c9b6f24e44db74 0740a6bbe2a702cb48cf037549ffb71941bf3f0f
remote: reject_external_email.sh: failed with exit status 1
remote: [Pre-receive Hook]: At least one commit on 'master' does not have an 'example.com' email address.
remote: [Pre-receive Hook]: commit: 0740a6bbe2a702cb48cf037549ffb71941bf3f0f
remote: [Pre-receive Hook]: author email: ci-pool@localhost
To example.com:user/concourse-locks.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@example.com:user/concourse-locks.git'

The commit was rejected since the current git server setup requires the email to follow a certain pattern, which is relatively common.

Checking the code https://github.com/concourse/pool-resource/blob/master/out/git_lock_handler.go#L194-L219 we found that currently, the username and email was hard-coded to always be CI Pool Resource and ci-pool@localhost, which cannot support cases like the above.

Would suggest adding additional source.git_config option similar to the one for git resource to better support git servers that have a stricter validations on git user/email patterns. Thank you,

bencao commented 5 years ago

Also can we show the failure reason for git push in log so that it will be easier to debug similar issues?

xtremerui commented 2 years ago

this shoule be fixed by https://github.com/concourse/pool-resource/pull/65