2010-12-09 12 views
7

Şu anda Hudson aşağıdaki özette bir dosya + alan yüklemek için bir çalışma yöntemi arıyorum. Şu anki sorun, Hudson'ın her zaman sunulması gereken bir formdan şikayet etmesidir ... (bu yazının ilerleyen bölümlerinde istisna bakınız).Bir Hudson yapısını tetiklemek için HTTP POST yoluyla dosya yükleme + parametresi

<dependency> 
    <groupId>org.apache.httpcomponents</groupId> 
    <artifactId>httpclient</artifactId> 
    <version>4.0.3</version> 
</dependency> 
<dependency> 
    <groupId>org.apache.httpcomponents</groupId> 
    <artifactId>httpcore</artifactId> 
    <version>4.0.1</version> 
    <type>jar</type> 
    <scope>compile</scope> 
</dependency> 
<dependency> 
    <groupId>org.apache.httpcomponents</groupId> 
    <artifactId>httpmime</artifactId> 
    <version>4.0.3</version> 
    <type>jar</type> 
    <scope>compile</scope> 

istisna şudur: Ama dokümanlar dayalı i aşağıdaki gibi

HttpPost httppost = new HttpPost(triggerJobUrl); 
FileBody fileBody = new FileBody(releaseProperties); 
StringBody stringBody = new StringBody(svnURL.toString()); 
MultipartEntity mentity = new MultipartEntity(); 
mentity.addPart("trunk/release.properties", fileBody); 
mentity.addPart("SVNURL", stringBody); 
httppost.setEntity(mentity); 
HttpResponse response = null; 
try { 
    response = httpClient.execute(httppost); 
} catch (ClientProtocolException e) { 
    throw new HudsonException("http protocol error.", e); 
} catch (IOException e) { 
    throw new HudsonException("connection aborted.", e); 
} 
if (response.getStatusLine().getStatusCode() != 200) { 
    throw new HudsonException("Unexpected status code received " + response.getStatusLine().getStatusCode()); 
} 
HttpEntity resEntity = response.getEntity(); 
if (resEntity != null) { 
    try { 
     resEntity.consumeContent(); 
    } catch (IOException e) { 
     throw new HudsonException(
       "if an I/O error occurs. This indicates that connection keep-alive is not possible.", e); 
    } 
} 

Bulunduğum Maven bağımlılıkları

vardır ... aşağıdaki Java kod parçacığı gibi çalışıyor olması gerekir okumak :

java.lang.Error: This page expects a form submission 
    at org.kohsuke.stapler.RequestImpl.getSubmittedForm(RequestImpl.java:769) 
    at hudson.model.ParametersDefinitionProperty._doBuild(ParametersDefinit 
+0

Merhaba, imagebin bağlantısı geçersiz olduğundan, sorunuzdan emin değilim. Http://illegalstateexception.blogspot.de/2010/11/triggering-hudson-parameterized-builds.html adresinde bir parametreli yapı için bir dosya yüklemek için bir yanıt gönderdim. –

+0

Aynı sorunu yaşıyorum, bunu düzelttiniz mi? – tipu

cevap

21

Muhtemelen url gibi bir iş kullanmanız/blabla/build ile çalışmanız gerekir iş/bl abla/buildWithParameters