Jenkinsパイプラインの実行後に、1つのTomcat内のすべてのWebアプリケーションが実行されていることを確認しようとしています。Jenkinsパイプラインループが予期せず終了する
私は複数のURLを検証していますので、forループでそれを行いたいと思います。 コレクションの最初のURLで終了します。ここで
は、私がverifyServices
にtestUrl
関数の呼び出しを削除するとここに私のコード
@NonCPS
def verifyServices(list) {
echo "Services: "+list.size()
def result = true
for(int i = 0; i < list.size(); i++){
if(result) {
result = testUrl(list[i])
}
}
return result
}
def verify = []
verify.add("http://example.com:8082")
verify.add("http://example.com:8082/rest/version")
verify.add("http://example.com:8082/mobile/version")
verifyServices(verify)
そしてtestUrl機能
def call(urlString) {
echo "Testing ${urlString}"
def url = new URL(urlString)
def HttpURLConnection connection = url.openConnection()
connection.setRequestMethod("GET")
connection.setDoInput(true)
try {
connection.connect()
def code = connection.getResponseCode()
echo "Response code ${code}"
return code == 200
} finally {
connection.disconnect()
}
}
は私のログは、それがすべてを反復処理
Proceeding
[Pipeline] echo
Services: 3
[Pipeline] echo
Testing http://example.com:8082
[Pipeline] echo
Response code 200
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ですそれら。
何か間違っていますか?またはループはちょうど壊れていますか?
forループは壊れていません –
素晴らしいです。だから私は間違っているの?私が関数を使うとき(または単に "echo test"をforループの中で繰り返し実行すると、反復が止まる... –
'testUrl'関数は' call'と呼ばれますか?例外を伴って呼び出されないのはなぜですか? _finally_ブロックがありますか? –