我想通过运行以下代码来获取http状态代码:“ C:\ Program Files \ cURL \ bin \ curl.exe” -s -o / dev / null -w“%{http_code}” localhost:8083在管道中但这不起作用。
但是,当我在窗口命令行上运行该代码时,它可以工作。
其他情况: 我尝试在管道中运行:“ C:\ Program Files \ cURL \ bin \ curl.exe” localhost:8083。结果成功。
所有程序都在窗口环境中运行。
node {
stage('statuscodeTest'){
bat '''
"C:\\Program Files\\cURL\\bin\\curl.exe" -s -o /dev/null -w "%{http_code}" localhost:8083
'''
}
}
我希望结果是200,因为localhost:8083可用
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\testbuildImage
[Pipeline] {
[Pipeline] stage
[Pipeline] { (statuscodeTest)
[Pipeline] bat
C:\Program Files (x86)\Jenkins\workspace\testbuildImage>"C:\Program Files\cURL\bin\curl.exe" -s -o /dev/null -w "8083
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 2
Finished: FAILURE