--- /dev/null
+"How To..." examples
+====================
+
+This directory contains a set of examples or recipes for common tasks in
+JenkinsAPI.
\ No newline at end of file
--- /dev/null
+"""
+A lower-level implementation of copying a job in Jenkins
+"""
+
+import requests
+from jenkinsapi.jenkins import Jenkins
+from pkg_resources import resource_string
+from jenkinsapi_tests.test_utils.random_strings import random_string
+
+J = Jenkins('http://localhost:8080')
+jobName = random_string()
+jobName2 = '%s_2' % jobName
+
+url = 'http://localhost:8080/createItem?from=%s&name=%s&mode=copy' % (
+ jobName, jobName2)
+
+xml = resource_string('examples', 'addjob.xml')
+j = J.create_job(jobname=jobName, config=xml)
+
+
+h = {'Content-Type': 'application/x-www-form-urlencoded'}
+response = requests.post(url, data='dysjsjsjs', headers=h)
+print response.text.encode('UTF-8')
--- /dev/null
+"""
+A low level example:
+This is how JenkinsAPI creates views
+"""
+import requests
+import json
+
+url = 'http://localhost:8080/createView'
+
+str_view_name = "blahblah123"
+params = {}# {'name': str_view_name}
+headers = {'Content-Type': 'application/x-www-form-urlencoded'}
+data = {
+ "name": str_view_name,
+ "mode": "hudson.model.ListView",
+ "Submit": "OK",
+ "json": json.dumps({"name": str_view_name, "mode": "hudson.model.ListView"})
+}
+# Try 1
+result = requests.post(url, params=params, data=data, headers=headers)
+print result.text.encode('UTF-8')
--- /dev/null
+import json
+import requests
+
+def foo():
+ """
+ A low level example of how JenkinsAPI runs a parameterized build
+ """
+ toJson = {'parameter':[{'name':'B', 'value':'xyz'}]}
+ url = 'http://localhost:8080/job/ddd/build'
+ #url = 'http://localhost:8000'
+ headers = {'Content-Type': 'application/x-www-form-urlencoded'}
+ form = {'json':json.dumps(toJson)}
+ response = requests.post(url, data=form, headers=headers)
+ print response.text.encode('UTF-8')
+
+if __name__ == '__main__':
+ foo()
+
--- /dev/null
+"""
+A lower level example of how we login with authentication
+"""
+
+from jenkinsapi import jenkins
+
+
+J = jenkins.Jenkins("http://localhost:8080", username = "sal", password = "foobar")
+J.poll()
+
+print J.items()
--- /dev/null
+Low-Level Examples
+==================
+
+These examoples are intended to explain how JenkinsAPI performs certain functions. While developing JenkinsAPI I created a number of small scripts like these in order to figure out the correct way to communicate. Ive retained a number of these as they provide some insights into how the various interfaces that Jenkins provides can be used.
\ No newline at end of file