开发者

Filtering Hudson build results by description

I need to filter the build results of a job based on the description of the build in Hudson. I found a plugin that allows for filtering based on the job description, however I开发者_开发技巧'm not sure how I would begin to do the same for builds.


Use Hudsons XML API with XPATH

http://<your hudson url>/api/xml?depth=1&xpath=//job/description[contains(./text(),'<search string>')]&wrapper=jobs

will show you the descriptions of all jobs that contain the given search string

with some more xpath magic you can probably get it to display the result of the latest build also (the path is job/lastBuild/result , possibly you need to increase the depth to 2)

consult the xml api at http://<your hudson url>/api for further reference

Edit:

http://<your hudson url>/api/xml?depth=2&xpath=child::hudson/job[contains(displayName,'<search string>')]/*[self::name or self::lastBuild]&wrapper=jobs

almost works for me, it shows the name and the last build, but unfortunately in a structure like this

<jobs>
    <name>job1</name>
    <lastBuild>
        <!-- snip a lot -->
        <result>SUCCESS</result>
        <!-- snip a lot -->
    </lastBuild>
    <name>job2</name>
    <lastBuild>
        <!-- snip a lot -->
        <result>SUCCESS</result>
        <!-- snip a lot -->
    </lastBuild>
</jobs>

whereas I'd prefer this:

<jobs>
    <job>
        <name>job1</name>
        <lastBuild>
            <!-- snip a lot -->
            <result>SUCCESS</result>
            <!-- snip a lot -->
        </lastBuild>
    </job>
    <job>
        <name>job2</name>
        <lastBuild>
            <!-- snip a lot -->
            <result>SUCCESS</result>
            <!-- snip a lot -->
        </lastBuild>
    </job>
</jobs>

can somebody provide the necessary xpath fine-tuning?


EDIT again

now I realized you want to read info about builds, not jobs, so use this code instead:

http://<your hudson url>/job/<your job name>/api/xml?depth=1&xpath=//build[contains(action/cause/shortDescription,'<search string>')]/*[self::result or self::number]&wrapper=builds
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜