我正在为企业Jenkins实例设置Jenkins棉绒。我正在遵循官方文档以使用Curl命令方法。我创建了一个Jenkinsfile,它进一步调用了Shell脚本。由于Jenkins实例未设置为匿名读取访问,因此我必须将凭据传递给curl命令。我正在使用詹金斯的凭据方法在env var中保存帐户的凭据。在curl命令中使用。但是,当curl命令在shell脚本中执行时,它会抛出错误,试图匿名访问。请让我知道我是否想念一些东西。
JENKINS_URL=https://ABCD
JENKINS_CRUMB=`curl "$JENKINS_URL/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)"`
curl -X POST --user $AUTH_CREDENTIALS -H $JENKINS_CRUMB -F "jenkinsfile=<Jenkinsfile" $JENKINS_URL/pipeline-model-converter/validate
Jenkins日志
Running shell script
+ scripts/jenkins_linting.sh
+ JENKINS_URL=https://ABCD
++ curl 'https://ABCD/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 983 100 983 0 0 1471 0 --:--:-- --:--:-- --:--:-- 1471
+ JENKINS_CRUMB='<html><head><meta http-equiv='\''refresh'\'' content='\''1;url=/login?from=%2FcrumbIssuer%2Fapi%2Fxml%3Fxpath%3Dconcat%28%2F%2FcrumbRequestField%2C%22%3A%22%2C%2F%2Fcrumb%29'\''/><script>window.location.replace('\''/login?from=%2FcrumbIssuer%2Fapi%2Fxml%3Fxpath%3Dconcat%28%2F%2FcrumbRequestField%2C%22%3A%22%2C%2F%2Fcrumb%29'\'');</script></head><body style='\''background-color:white; color:white;'\''>
Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:
Permission you need to have (but didn'\''t): hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
-->
</body></html> '
+ curl -X POST --user **** -H '<html><head><meta' 'http-equiv='\''refresh'\''' 'content='\''1;url=/login?from=%2FcrumbIssuer%2Fapi%2Fxml%3Fxpath%3Dconcat%28%2F%2FcrumbRequestField%2C%22%3A%22%2C%2F%2Fcrumb%29'\''/><script>window.location.replace('\''/login?from=%2FcrumbIssuer%2Fapi%2Fxml%3Fxpath%3Dconcat%28%2F%2FcrumbRequestField%2C%22%3A%22%2C%2F%2Fcrumb%29'\'');</script></head><body' 'style='\''background-color:white;' 'color:white;'\''>' Authentication required '<!--' You are authenticated as: anonymous Groups that you are in: Permission you need to have '(but' 'didn'\''t):' hudson.model.Hudson.Read ... which is implied by: hudson.security.Permission.GenericRead ... which is implied by: hudson.model.Hudson.Administer '-->' '</body></html>' -F 'jenkinsfile=<Jenkinsfile' https://ABCD/pipeline-model-converter/validate
curl: option -->: is unknown
curl: try 'curl --help' or 'curl --manual' for more information
谢谢
山地