2015-07-10 12 views

Trả lời

8

Xem Jenkins' Remote access API.

Tiếp cận mô tả API với:

http://<Your Jenkins>/api/ 

và dữ liệu thực tế với:

http://<Your Jenkins>/api/xml 

Hàng đợi xây dựng có API riêng biệt của riêng mình:

http://<Your Jenkins>/queue/api/ 

với dữ liệu của nó:

http://<Your Jenkins>/queue/api/xml 
0

Hãy thử Jenkins API in Python.

get_jobs() 
    Get list of jobs running. 
    Each job is a dictionary with ‘name’, ‘url’, and ‘color’ keys. 
Returns: list of jobs, [ { str: str} ] 
3

Đó là dễ dàng để làm với Jenkins Script Console:

println Hudson.instance.queue.items.length 
// => 2 

Ngoài ra đó là có thể thực hiện kịch bản hấp dẫn từ xa. Ví dụ, từ dòng lệnh:

$ curl -u username:password -d "script=println Hudson.instance.queue.items.length" jenkins_url/scriptText 
2 

Note: người dùng với quy định tên nên có quyền truy cập vào Jenkins Script Console.

+1

Lưu ý trong các phiên bản gần đây, các cuộc gọi tại là 'Jenkins.instance.queue.items.size() ', hoặc nếu bạn gọi nó từ một kịch bản, 'jenkins.model.Jenkins.instance.queue.items.size()' – jpyams

2

Đây là một thực hiện kịch bản shell của đề cập Jenkins REST API

_queuesize=$(curl -s -k -m 60 http://${yourjenkinsserver}:8180/jenkins/queue/api/xml 2>/dev/null | grep -c '<item>') 
if [[ -z "${_queuesize}" ]]; then 
    _queuesize=0; 
fi 
+1

Đối với tôi, tôi đã phải loại bỏ "jenkins" khỏi url: http: // $ {yourjenkinsserver}: 8180/queue/api/xml –

Các vấn đề liên quan