Views ======== Views ----------- .. _views: Search for a view .. autofunction:: views.Views.search() .. code-block:: python from jenkins_pysdk.jenkins import Jenkins jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608") print(jenkins.views.search("All")) The above code will output: :: Iterate all views .. autofunction:: views.Views.iter() .. code-block:: python from jenkins_pysdk.jenkins import Jenkins jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608") for view in jenkins.views.iter(): print(view.name) The above code will output: :: all m my List all views .. autofunction:: views.Views.list() .. code-block:: python from jenkins_pysdk.jenkins import Jenkins jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608") print(jenkins.views.list()) The above code will output: :: [, , ] Create a view .. autofunction:: views.Views.create() .. code-block:: python from jenkins_pysdk.jenkins import Jenkins jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608") xml = """ my_view hudson.model.ListView Your view description new_freestyle true """ print(jenkins.views.create("my_view", xml)) The above code will output: :: request= content='[200] Successfully created my_view.' status_code=200 View ----------- .. _view: Get the view name .. autofunction:: views.View.name() .. code-block:: python from jenkins_pysdk.jenkins import Jenkins jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608") print(jenkins.views.search("All").name) The above code will output: :: All Get the view URL .. autofunction:: views.View.url() .. code-block:: python from jenkins_pysdk.jenkins import Jenkins jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608") print(jenkins.views.search("All").url) The above code will output: :: http://JenkinsDNS/view/All Reconfigure the view (Job order must be the same as the order in the application, otherwise you will get dodgy results) E.g. builder_e is higher up in the list of jobs so it goes above builder_folder, which is underneath it in the list :) .. autofunction:: views.View.reconfig() .. code-block:: python from jenkins_pysdk.jenkins import Jenkins jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608") xml = """ my_view Your view description false false builder_e builder_folder builder_w new_freestyle true """ print(jenkins.views.search("my_view").reconfig(xml)) The above code will output: :: request= content='[200] Successfully reconfigured view (my_view).' status_code=200 Delete the view .. autofunction:: views.View.delete() .. code-block:: python from jenkins_pysdk.jenkins import Jenkins jenkins = Jenkins(host="JenkinsDNS", username="admin", token="11e8e294cee85ee88b60d99328284d7608") print(jenkins.views.search("YourViewName").delete()) The above code will output: :: request= content='[200] Successfully deleted view (YourViewName).' status_code=200