Jenkins的get接口操作

# coding=utf-8

import json
import requests
import unittest
from requests.auth import HTTPBasicAuth


class JenkinsGetTestCase(unittest.TestCase):
    def setUp(self):
        self.r = requests.get('http://192.168.217.130:8080/jenkins/api/json?tree=jobs[name]')

    def test_getAllJobsName(self):
        result = self.r.text
        json_result = json.loads(result)
        print json_result

        self.assertEqual(json_result['jobs'][0]['name'], 'check_python_version')

    def test_getAllJobsNameSimple(self):
        json_result = self.r.json()
        self.assertEqual(json_result['jobs'][0]['name'], 'check_python_version')

    # 测试开启鉴权的接口-禁用某个job

if __name__ == '__main__':
    unittest.main()

    原文作者:七月尾巴_葵花
    原文地址: https://www.jianshu.com/p/5d145fdad758
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞