forked from shunyeka/JenkinsConfigurationUsingApi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
42 lines (29 loc) · 969 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from flask import Flask, jsonify, request
from flask_cors import CORS
from jenkins_job_configuration import JenkinsApi
app = Flask(__name__)
CORS(app)
@app.route('/')
def homepage():
return "Now you can configure jenkins job using the Python Flask API!!!!!"
@app.route('/jobs', methods=["GET"])
def get_all_job():
result = JenkinsApi().get_all_jobs()
return jsonify(result)
@app.route('/jobs', methods=["POST"])
def create_job_using_api():
data = request.json
result = JenkinsApi().create_job(data["name"], data["project_type"])
return jsonify(result)
@app.route('/builds', methods=["POST"])
def build_job_using_api():
data = request.json
result = JenkinsApi().build_job(data["name"])
return jsonify(result)
@app.route('/jobs', methods=["DELETE"])
def delete_job_using_api():
data = request.json
result = JenkinsApi().delete_job(data["name"])
return jsonify(result)
if __name__ == '__main__':
app.run()