差異處
這裏顯示兩個版本的差異處。
Both sides previous revision 前次修改 下次修改 | 前次修改 | ||
jenkins:restapi:get_artifacts [2016/12/23 23:41] tony [Sample code] |
jenkins:restapi:get_artifacts [2023/06/25 09:48] (目前版本) |
||
---|---|---|---|
行 85: | 行 85: | ||
http://tonylin.idv/job/Example/api/json?tree=builds[description,result,displayName,url] | http://tonylin.idv/job/Example/api/json?tree=builds[description,result,displayName,url] | ||
</code> | </code> | ||
- | 三個build的輸出結果如下,從結果內容不難得知個別資訊意義,需注意的是master的description會是null: | + | 三個build的輸出結果如下,從結果內容不難得知個別資訊意義,需注意的是master的description會是null或master(我們使用dscription當branch名稱): |
<code> | <code> | ||
{ | { | ||
行 156: | 行 156: | ||
found_build = None | found_build = None | ||
for build in json_object["builds"]: | for build in json_object["builds"]: | ||
- | if build["description"] == branch: | + | if not branch and build["description"] == "master": |
- | found_build = build | + | return build |
- | break | + | elif build["description"] == branch: |
- | if found_build: | + | return build |
- | return found_build | + | |
return None | return None | ||
行 181: | 行 180: | ||
return None | return None | ||
</code> | </code> | ||
- | 測試案例: | + | 簡單的測試案例: |
<code python> | <code python> | ||
from unittest import TestCase | from unittest import TestCase |