请求中没有包含有效的碎屑 Jenkins 2.192 git 钩子
No valid crumb was included in the request Jenkins 2.192 git hooks
我在网上试了很多办法,还是没法解决。在 jenkins Global security 中,我勾选了 Prevent Cross Site Request Forgery exploits with enable proxy compatibility。我也尝试过不使用 Prevent Cross Site Request Forgery 漏洞,它会导致创建面包屑。我的jenkins URL 也是对的
我的post-接收文件是这样的,
#!/bin/bash
# Get branch name from ref head
if ! [ -t 0 ]; then
read -a ref
fi
IFS='/' read -ra REF <<< "${ref[2]}"
branch="${REF[2]}"
if [ "$branch" == "master" ]; then
crumb=$(curl -u "jenkins:1234" -s 'http://jenkins:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
curl -u "jenkins:1234" -H "$crumb" -X POST http://jenkins:8080/job/maven/build?delay=0sec
if [ $? -eq 0 ] ; then
echo "*** Ok"
else
echo "*** Error"
fi
fi
错误消息是
HTTP ERROR 403
为此我发现了不安全的答案:-)。但它有效。我所做的是禁用 Prevent Cross Site Request Forgery exploits 并从 post-receive 文件中删除与 crumb 相关的行。新的 post 接收文件如下所示。
#!/bin/bash
# Get branch name from ref head
if ! [ -t 0 ]; then
read -a ref
fi
IFS='/' read -ra REF <<< "${ref[2]}"
branch="${REF[2]}"
if [ "$branch" == "master" ]; then
#crumb=$(curl -u "jenkins:1234" -s 'http://jenkins:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
#echo"******************************"
echo "$crumb"
#echo"******************************"
curl -u "jenkins:1234" -H -X POST http://jenkins:8080/job/maven-job/build?delay=0sec
if [ $? -eq 0 ] ; then
echo "*** Ok"
else
echo "*** Error"
fi
fi
如果有人能提供更好的答案,我们将不胜感激。
我在网上试了很多办法,还是没法解决。在 jenkins Global security 中,我勾选了 Prevent Cross Site Request Forgery exploits with enable proxy compatibility。我也尝试过不使用 Prevent Cross Site Request Forgery 漏洞,它会导致创建面包屑。我的jenkins URL 也是对的
我的post-接收文件是这样的,
#!/bin/bash
# Get branch name from ref head
if ! [ -t 0 ]; then
read -a ref
fi
IFS='/' read -ra REF <<< "${ref[2]}"
branch="${REF[2]}"
if [ "$branch" == "master" ]; then
crumb=$(curl -u "jenkins:1234" -s 'http://jenkins:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
curl -u "jenkins:1234" -H "$crumb" -X POST http://jenkins:8080/job/maven/build?delay=0sec
if [ $? -eq 0 ] ; then
echo "*** Ok"
else
echo "*** Error"
fi
fi
错误消息是 HTTP ERROR 403
为此我发现了不安全的答案:-)。但它有效。我所做的是禁用 Prevent Cross Site Request Forgery exploits 并从 post-receive 文件中删除与 crumb 相关的行。新的 post 接收文件如下所示。
#!/bin/bash
# Get branch name from ref head
if ! [ -t 0 ]; then
read -a ref
fi
IFS='/' read -ra REF <<< "${ref[2]}"
branch="${REF[2]}"
if [ "$branch" == "master" ]; then
#crumb=$(curl -u "jenkins:1234" -s 'http://jenkins:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
#echo"******************************"
echo "$crumb"
#echo"******************************"
curl -u "jenkins:1234" -H -X POST http://jenkins:8080/job/maven-job/build?delay=0sec
if [ $? -eq 0 ] ; then
echo "*** Ok"
else
echo "*** Error"
fi
fi
如果有人能提供更好的答案,我们将不胜感激。