a lower-level example of how parameterized builds work in Jenkins
authorsalimfadhley <sal@stodge.org>
Wed, 12 Jun 2013 00:59:01 +0000 (01:59 +0100)
committersalimfadhley <sal@stodge.org>
Wed, 12 Jun 2013 00:59:01 +0000 (01:59 +0100)
examples/example_param_build.py [new file with mode: 0644]

diff --git a/examples/example_param_build.py b/examples/example_param_build.py
new file mode 100644 (file)
index 0000000..ff076a0
--- /dev/null
@@ -0,0 +1,20 @@
+import json
+import requests
+
+def foo():
+    """
+    A low level example of how to run a parameterized build in Jenkins
+    from Python.
+    """
+    data={'B':'abc'}
+    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()
+