Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

从script传递参数,增加获取github event name #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lloydzhou
Copy link

No description provided.

@lloydzhou lloydzhou mentioned this pull request Jul 13, 2017
@@ -6,6 +6,11 @@
'''


# event name
def get_event_name(request):
return request.headers.get('X-GitHub-Event')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

希望能够兼容 github、gitlab、gitosc 三个 git 服务,具体额 json 结构在这里都可以看得到。

https://github.com/hustcc/webhookit/tree/master/tests/webhookdata

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gitosc的没有找到对应的头信息,所以从hook_data读取了hook_name。
另外几个站点都使用了头信息里面的X-**-Event的值

# 需要出发操作的服务器 server 数组
servers = config.get(webhook_key, [])
if servers and len(servers) > 0:
# 存在 server,需要执行 shell 脚本
cnt = 0
for s in servers:
# 遍历执行
s['SCRIPT'] = s.get('SCRIPT').format(**params)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string.format(dict) 的输出是什么?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外这里可能有一个值引用修改的问题:

s['SCRIPT'] = s.get('SCRIPT').format(**params)

直接修改了原始配置中的 script 值,后面每次执行都会追加参数进去,这个你也可以再确认一下!

@hustcc
Copy link
Owner

hustcc commented Sep 27, 2017

不好意思,这段时间一忙就忘记了,我又 review 了一下你的代码!可能存在 bug,你再确认一下~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants