@@ -24,6 +24,7 @@ class Redmine implements \PHPCI\Plugin
24
24
protected $ enabled = true ;
25
25
26
26
protected $ status ;
27
+ protected $ prevStatus ;
27
28
protected $ percent ;
28
29
29
30
protected $ lang = 'en ' ;
@@ -50,6 +51,9 @@ public function __construct(Builder $phpci, Build $build, array $options = array
50
51
if (isset ($ options ['status ' ])) {
51
52
$ this ->status = $ options ['status ' ];
52
53
}
54
+ if (isset ($ options ['prev_status ' ])) {
55
+ $ this ->prevStatus = $ options ['prev_status ' ];
56
+ }
53
57
if (isset ($ options ['percent ' ])) {
54
58
$ this ->percent = $ options ['percent ' ];
55
59
}
@@ -91,7 +95,32 @@ public function execute()
91
95
$ issue ['notes ' ] .= sprintf ($ this ->messages ['passed ' ], $ buildLink ) . "\n" ;
92
96
93
97
if ($ this ->status ) {
94
- $ issue ['status_id ' ] = $ this ->status ;
98
+ if ($ this ->prevStatus ) {
99
+ $ headers = array (
100
+ 'Content-Type: application/json ' ,
101
+ 'X-Redmine-API-Key: ' . $ this ->apiKey ,
102
+ );
103
+
104
+ $ ch = curl_init ();
105
+ curl_setopt ($ ch , CURLOPT_URL , $ url );
106
+ curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ headers );
107
+ curl_setopt ($ ch , CURLOPT_FAILONERROR , false );
108
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 ); // return into a variable
109
+ curl_setopt ($ ch , CURLOPT_TIMEOUT , 30 ); // times out after 30s
110
+
111
+ $ response = curl_exec ($ ch );
112
+ $ response = json_decode ($ response );
113
+
114
+ if ($ response ) {
115
+ if (isset ($ response ['issue ' ]['status ' ]['id ' ])) {
116
+ if ($ this ->prevStatus == $ response ['issue ' ]['status ' ]['id ' ]) {
117
+ $ issue ['status_id ' ] = $ this ->status ;
118
+ }
119
+ }
120
+ }
121
+ } else {
122
+ $ issue ['status_id ' ] = $ this ->status ;
123
+ }
95
124
}
96
125
if ($ this ->percent ) {
97
126
$ issue ['done_ratio ' ] = $ this ->percent ;
0 commit comments