[QuickBuild] RESTful API로 빌드 요청

QuickBuild를 이용할 때, 굳이 사이트에 접속해서 빌드를 돌리지 않아도 RESTful API를 이용하면 빌드를 걸 수 있다.

http://wiki.pmease.com/display/QB61/Interact+with+Build+Requests#InteractwithBuildRequests-requestnewbuild 에 해당 내용이 정리되어 있다.

Basic authentication 시에 curl을 이용해서 요청하는 방법은 다음과 같다.

$ curl -X POST -u dasomoli:password -d@request.xml http://<Server>:8810/rest/build_requests

위의 예제에서 사용한 request.xml 은 다음의 형식을 가진다. <varlables> 안에 채울 내용은 해당 configuration에서 실행한 빌드의 variables(http://<Server>:8810/build/<Build id>/variables) 페이지에서 확인 가능하다.

<com.pmease.quickbuild.BuildRequest>
  <!-- This element tells QuickBuild in what configuration to trigger build. -->
  <configurationId>10</configurationId>

  <!-- This element tells whether or not to respect build condition of the configuration. 
       If this is set to true, and if the build condition evaluates to false, build will 
       not be triggered. -->
  <respectBuildCondition>false</respectBuildCondition>

  <!-- This element is optional and is used to specify variables for build triggering. If 
       specified, it will override the variable with the same name defined in configuration
       basic setting. -->
  <variables>
    <entry>
      <string>var_name1</string>
      <string>var_value1</string>
    </entry>
    <entry>
      <string>var_name2</string>
      <string>var_value2</string>
    </entry>
  </variables>

  <!-- This element is optional and is used to tell QuickBuild to request a build promotion. -->
  <promotionSource>

    <!-- This element is optional and is used to tell QuickBuild that the source build resides on another 
         QuickBuild server. -->
    <server>
      <url>http://another-qb-server:8810</url>
      <userName>admin</userName>
      <password>admin</password>
    </server>

    <!-- Identifier of the source build to promote from -->
    <buildId>697</buildId>

    <!-- This element is optional and used to specify files to promote -->
    <deliveries>
      <com.pmease.quickbuild.FileDelivery>
        <srcPath>artifacts/dir1</srcPath>
        <filePatterns>**/*.jar</filePatterns>
      </com.pmease.quickbuild.FileDelivery>
      <com.pmease.quickbuild.FileDelivery>
        <srcPath>artifacts/dir2</srcPath>
        <filePatterns>**/*.war</filePatterns>
      </com.pmease.quickbuild.FileDelivery>
    </deliveries>
  </promotionSource>

</com.pmease.quickbuild.BuildRequest>

Sample XML의 comment에서 확인할 수 있듯이 <promotionSource>내부는 생략 가능하다.