-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjenkins-api.php
More file actions
119 lines (43 loc) · 1.62 KB
/
jenkins-api.php
File metadata and controls
119 lines (43 loc) · 1.62 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
ob_start();
error_reporting(E_ALL ^ E_NOTICE);
require "includes/config.php";
require "includes/sess.php";
session_start();
if( $_SESSION['loggedIn'] !== TRUE ){
header('HTTP/1.0 401 Unauthorized');
exit;
}
require_once("vendor/jenkins-php-api/Jenkins/__init__.php");
require_once("vendor/jenkins-php-api/Jenkins.php");
$jenkins = new Jenkins("http://10.0.90.82:8080");
if ( $_GET['jenkinsProjList'] === "true" ){
if( $jenkins->isAvailable() ){
echo json_encode($jenkins->getAllJobs());
}
}
if( $_POST['buildJob'] === "true" ){
$jobName = rawurldecode($_POST['jobName']);
if( $jenkins->isAvailable() ){
if( isset($jobName) && $jobName != "" ){
$jenkins->launchJob($jobName);
}else{
echo "Parameter not set: JobName";
}
}
}
if ( $_GET['projList'] === "true" ){
$rel = mysql_real_escape_string((integer)$_GET['rel']);
if( isset($rel) && $rel != "" && $rel != 0 ) {
$rel_project_list = mysql_query("select relation_id AS rel, auto_name AS name From table_automation WHERE relation_id = '{$rel}'") or die("Can't get DB builds");
if( $rel_project_list ){
while ($projects = mysql_fetch_object($rel_project_list)){
echo "<div id='auto-container'>";
echo "<div class='related-builds'>{$projects->name}<button class='related-builds-btn' onclick='xTable.launchJob(this.value)' id='' value='{$projects->name}'>Execute</button></div>";
echo "<div class='related-builds-real-time'><span class='realtime-results'>Real Time Results</span></div>";
echo "</div>";
}
}
}else{ echo "Rel was not provided"; }
}
?>