大家早上好
我想创建一个脚本,当有人根据pull request注释在我们的GitHub上发出pull请求时,自动更新RedMine上的问题。在
我用Python编写了一个脚本,使用selenium和redmine restapi检索请求者对GitHub发出的请求的注释,但我必须手动执行它。
你知道在pull请求之后是否可以自动执行python脚本?在
(目前脚本存储在我的计算机上,但理想情况下,它将存储在外部服务器上,以便我和我的合作伙伴可以更轻松地使用它)
我已经搜索了一些基于WebHooks或CRON的解决方案,但似乎没有什么能回答我的问题。在
我使用的是python2.7
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import test
# Xpath to retrieve number of the fix
DISCONNECTED_XPATH = "//div[4]/div/main/div[2]/div[1]/div/div[2]/div[3]/div[2]/div[1]/div[1]/div[2]/div/div[2]/task-lists/table/tbody/tr/td/p"
CONNECTED_XPATH = "//div[4]/div/main/div[2]/div[1]/div/div[1]/div[3]/div[2]/div[1]/div[1]/div[2]/div/div[2]/task-lists/table/tbody/tr/td/p"
PULL_URL = "https://github.com/MaxTeiger/TestCoopengo/pull/1"
# Init
print("Opening the browser...")
driver = webdriver.Firefox()
# Go to the specified pull
print("Reaching " + PULL_URL)
driver.get(PULL_URL)
assert "GitHub" in driver.title
print("Finding the pull comment...")
# retrieve the fix id
elem = driver.find_element_by_xpath(DISCONNECTED_XPATH)
issueID = elem.text
print("Closing driver")
driver.close()
issueID = int(issueID.split('#')[1])
print("Issue ID : " +str(issueID))
print("Updating ticket on RedMine...")
test.updateIssueOnRedMineFromGit(issueID, PULL_URL)
如果你能帮助我或者你有更好的办法解决我的问题,谢谢你
我终于找到了问题的答案,结果发现GitHub提出的webhook解决了我的问题(Repo>;Settings>;webhooks)。在
现在,我只需要设置一个服务器,在我发出htmlpost请求时调用我的脚本,但是我不知道如何检索想要的pull请求的URL。在
相关问题 更多 >
编程相关推荐