2016-08-19 7 views
0

次のようなGroovyスクリプトがあります。 - 特定のジョブのすべてのビルドをチェックして、現在のビルドと同じビルドパラメータがあるかどうか確認します。 - 同じパラメータでビルドを停止します。現在のビルドgroovyスクリプトでの問題

import hudson.tasks.Ant 

def myBuildNumber = build.getEnvVars()['BUILD_NUMBER'].toInteger(); 
def myFractureNO = build.getEnvVars()['FRACTURE_NO'].toInteger(); 


def projectXml = new XmlSlurper().parseText("curl http://test.corp.test.com:8080/job/FractureAUT/api/xml".execute().text); 

projectXml.build.each { 
    if(it.number.toInteger() < myBuildNumber) 
    { 
     def jobXml = new XmlSlurper().parseText(("curl http://test.corp.test.com:8080/job/FractureAUT/" + it.number + "/api/xml").execute().text); 

     def myparams = jobXml.getAction(hudson.model.ParametersAction.class); 
     for(p in myparams) { 
      printlin p.name.toString(); 
      if (p.name.toString == "FRACTURE_NO") { 
       if (p.value.toString() == myFractureNO.toString()) { 
       "curl http://test.corp.adobe.com:8080/job/FractureAUT/" + it.number + "/stop".execute().waitFor(); 
       break; 
       } 
      } 
     } 

    } 
} 

は、スクリプトがあるためラインの画面へのURLの束を出力します

def projectXml = new XmlSlurper().parseText("curl http://test.corp.test.com:8080/job/FractureAUT/api/xml".execute().text); 

、それはそれを行うと仮定何をしません。

def projectXml = new XmlSlurper().parseText("curl http://test.corp.test.com:8080/job/FractureAUT/api/xml".execute().text); 

私は画面にURLを出力しないようにするにはどうすればよいですか?

I取得するには、次の出力

189http://test.corp.test.com:8080 /仕事/ FractureAUT/189/188http://test.corp.test.com:8080 /仕事/FractureAUT/188/187http://test.corp.test.com:8080/job/FractureAUT/187/186http://test.corp.test.com:8080/job/FractureAUT/186/185http://test .corp.test.com:8080/job/FractureAUT/185/184http://test.corp.test.com:8080/job/FractureAUT/184/183http://test.corp.test.com:8080/job /FractureAUT/183/182http://test.corp.test.com:8080/job/FractureAUT/182/181http://test.corp.test.com:8080/job/FractureAUT/181/179http://test .corp.test.com:8080/job/FractureAUT/179/178http://test.corp.test.com:8080/job/FractureAUT/178/177http://test.corp.test.com:8080/job /FractureAUT/177/176http://test.corp.test .com:8080/job/FractureAUT/176/174http://test.corp.test.com:8080/job/FractureAUT/174/173http://test.corp.test.com:8080/job/FractureAUT/173/172http: .com:8080/job/FractureAUT/170/169http://test.corp.test.com:8080/job/FractureAUT/169/168http://test.corp.test.com:8080/job/FractureAUT/168 /167http://test.corp.test.com:8080/job/FractureAUT/167/166http://test.corp.test.com:8080/job/FractureAUT/166/165http://test.corp.test .com:8080/job/FractureAUT/165/164http://test.corp.test.com:8080/job/FractureAUT/164/163http://test.corp.test.com:8080/job/FractureAUT/163 /162http://test.corp.test.com:8080/job/FractureAUT/162/161http://test.corp.test.com:8080/job/FractureAUT/161/160http://test.corp.test .com:8080/job/FractureAUT/160/159http://test.corp.test.com:8080/job/FractureAUT/159/158http://test.corp.test.com:8080/job/FractureAUT/158 /157http://test.corp.test.com:8080/job/FractureAUT/15 7/156http://test.corp.test.com:8080/job/FractureAUT/156/155http://test.corp.test.com:8080/job/FractureAUT/155/154http://test.corp。// 152/151http://test.corp.test.com:8080/job/FractureAUT/151/150http://test.corp.test.com:8080/job/FractureAUT/150/148http://test.corp。 test.com:8080/job/FractureAUT/148/146http://test.corp.test.com:8080/job/FractureAUT/146/144http://test.corp.test.com:8080/job/FractureAUT/ 144/143http://test.corp.test.com:8080/job/FractureAUT/143/142http://test.corp.test.com:8080/job/FractureAUT/142/141http://test.corp。 test.com:8080/job/FractureAUT/141/140http:/ /テスト139/138http://test.corp.test.com:8080/job/FractureAUT/138/137http://test.corp.test.com:8080/job/FractureAUT/137/136http://test.corp。 test.com:8080/job/FractureAUT/136/135http://test.corp.test.c :8080/job/FractureAUT/133/134http://test.corp.test.com:8080/job/FractureAUT/134/133http://test.corp.test.com:8080/job/FractureAUT/133/132http://test.corp.test.com:8080/job/FractureAUT/132/131http://test.corp.test.com:8080/job/FractureAUT/131/130http://test.corp.test。ジョブ/ FractureAUT/128 /ジョブ/ FractureAUT/129/128http://test.corp.test.com:8080/job/FractureAUT/128/127http://test.corp.test.com:8080/job/FractureAUT/127/126http://test.corp.test.com:8080/job/FractureAUT/126/125http://test.corp.test。ジョブ/ FractureAUT/123/124http://test.corp.test.com:8080/job/FractureAUT/124/123http://test.corp.test.com:8080/job/FractureAUT/123/122http://test.corp.test.com:8080/job/FractureAUT/122/121http://test.corp.test。FractureAUT/120/119http://test.corp.test.com:8080/job/FractureAUT/119/120http://test.corp.test.com:8080/job/FractureAUT/120/119http://test.corp.test.com:8080/job/FractureAUT/119/118http://test.corp.test.com:8080/job/FractureAUT/118/117http://test.corp.test.com:8080/job/FractureAUT/117/116http://test.corp.test。 FractureAUT/115/114http://test.corp.test.com:8080/job/FractureAUT/116/115http://test.corp.test.com:8080/job/FractureAUT/115/114http://test.corp.test.com:8080/job/FractureAUT/114/113http://test.corp.test.com:8080/job/FractureAUT/113/112http://test.corp.test.com:8080/job/FractureAUT/112/111http://test.corp.test。テスト/テスト/テスト/テスト/テスト/テスト/テスト/テスト/テスト/テスト/テスト/ 108http://test.corp.test.com:8080/job/FractureAUT/108/107http://test.corp.test.com:8080/job/FractureAUT/107/106http://test.corp.test。テスト/テスト/テスト/テスト/テスト/テスト/テスト/テスト/テスト/テスト/テスト/ 103http://test.corp.test.com:8080/job/FractureAUT/103/1082/http: .com:8080/job/FractureAUT/100/99http://test.corp.test.com:8080/job/FractureAUT/99/98http://test.corp.test.com:8080/job/FractureAUT/98 /97http://test.corp.test.com:8080/job/FractureAUT/97/96http://test.corp.test.com:8080/job/FractureAUT/96/95http://test.corp.test .com:8080/job/FractureAUT/95/94http://test.corp.test.com:8080/job/FractureAUT/94/93http://test.corp.test.com:8080/job/FractureAUT/93 /92http://test.corp.test.com:8080/job/FractureAUT/92/91http://test.corp.test.com:8080/job/FractureAUT/91/90http://test.corp.test .com:8080/job/FractureAUT/90/89http://test.corp.test.com:8080/job/FractureAUT/89/88http://test.corp.test.com:8080/job/FractureAUT/88 /87http://test.corp.test.com:8080/job/FractureAUT/87/86http://test.corp.test.com:8080/job/FractureAUT/86/85http://test.corp.test .com:8080 /職業/ FractureAUT/85/

なぜ出力は上になるのですか?

+0

質問はここにどこかにありますか? ;-) – BalRog

+0

私は分かりません。あなたは解析されたXML上で 'text'を呼び出しています。これは文字列を返します。返されたXMLとして処理したくないですか? –

+0

文字列がコンソールに出力されます。文字列を画面に出力しないようにしたいのですが、 – Jasmine

答えて

1

をあなたは全くカール呼び出しているのはなぜ?ただ、かっこいいからURLの内容を取得:

def xmlString = new URL("http://test.corp.test.com:8080/job/FractureAUT/api/xml").getText() 
def projectXML = new XMLSlurper().parseText(xmlString) 
+0

私はまだ次の出力を得ています://test.corp.test.com:8080/job/FractureAUT/189/188http://test.corp.test.com:8080/job/FractureAUT/188/187http://test.corp.test.com:8080/job/FractureAUT/187/186 – Jasmine

0

私は画面上の出力がcurlのためだと思います。だから、-sまたは--silentオプションでそれを黙らしようとすることができます:

def projectXml = new XmlSlurper().parseText("curl -s 'http://test.corp.test.com:8080/job/FractureAUT/api/xml'".execute().text); 
+0

は機能しませんでした。申し訳ありません – Jasmine

+0

出力は何ですか? – alpert

+0

URLの束 – Jasmine

1

XmlSlurperが直接URLを解析することができます

def projectXml = new XmlSlurper().parse('http://test.corp.test.com:8080/job/FractureAUT/api/xml') 
関連する問題