如何使用Git Hooks触发本地git存储库的Jenkins管道?

时间:2019-05-22 14:40:18

标签: git jenkins

我确定我在这里错过了一个把戏。这是我的post-commit Git Hook:

#!/bin/sh
#
# Run a build on commit.

CRUMB=$(curl -s 'http://admin:1qaz@localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')

curl -d "delay=0sec" -H ${CRUMB} -X POST http://localhost:8080/job/MYPROJECT/build

我正在尝试从终端手动测试它。当我运行CRUMB分配行并回显$ CRUMB时,我得到了预期的结果:

Jenkins-Crumb:95836aaf08889c06f0abe7a417cd65d9

但是从命令行,当我尝试步骤2时,我得到了Error 403 No valid crumb was included in the request。怎么回事?


已回答:

忘了我问!

很显然,我是个白痴……答案缺少凭据。

#
# Run a build on commit.

CRUMB=$(curl -s 'http://admin:1qaz@localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')

curl -d "delay=0sec" -H ${CRUMB} -X POST http://admin:1qaz@localhost:8080/job/web-frontend/build

0 个答案:

没有答案