Index: trunk/tools/subversion/hooks/HooksCommon.inc |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | 'pingURL' => array( |
62 | 62 | 'http://www.mediawiki.org/w/api.php?action=codeupdate&format=xml&repo=MediaWiki&rev=$REV', |
63 | 63 | ), |
64 | | - 'pingURL' => array( |
| 64 | + 'pingJenkins' => array( |
65 | 65 | 'http://ci2.tesla.usability.wikimedia.org:8080/subversion/$UUID/notifyCommit?rev=$REV', |
66 | 66 | ), |
67 | 67 | ); |
— | — | @@ -106,7 +106,7 @@ |
107 | 107 | */ |
108 | 108 | public function runPostCommitPings() { |
109 | 109 | foreach( $this->postCommitPings as $ping => $params ) { |
110 | | - call_user_func_array( array( $this, $test ), $params ); |
| 110 | + call_user_func_array( array( $this, $ping ), $params ); |
111 | 111 | } |
112 | 112 | return 0; |
113 | 113 | } |
— | — | @@ -116,7 +116,7 @@ |
117 | 117 | * |
118 | 118 | * @return string |
119 | 119 | */ |
120 | | - private function getLogMessage() { |
| 120 | + protected function getLogMessage() { |
121 | 121 | $output = null; |
122 | 122 | $cmd = "{$this->svnlook} log -t '{$this->transaction}' '{$this->repo}'"; |
123 | 123 | exec( $cmd, $output ); |
— | — | @@ -128,7 +128,7 @@ |
129 | 129 | * |
130 | 130 | * @return string |
131 | 131 | */ |
132 | | - private function getAuthor() { |
| 132 | + protected function getAuthor() { |
133 | 133 | $output = null; |
134 | 134 | $cmd = "{$this->svnlook} author -t '{$this->transaction}' '{$this->repo}'"; |
135 | 135 | exec( $cmd, $output ); |
— | — | @@ -140,7 +140,7 @@ |
141 | 141 | * |
142 | 142 | * @return array filenames are keys and status letters are values |
143 | 143 | */ |
144 | | - private function getCommitList() { |
| 144 | + protected function getCommitList() { |
145 | 145 | $output = null; |
146 | 146 | $cmd = "{$this->svnlook} changed -t '{$this->transaction}' '{$this->repo}'"; |
147 | 147 | exec( $cmd, $output ); |
— | — | @@ -161,7 +161,7 @@ |
162 | 162 | * @param $fileTypes array of file types used for filtering |
163 | 163 | * @return array |
164 | 164 | */ |
165 | | - private function getChangedFiles( array $fileTypes = array() ) { |
| 165 | + protected function getChangedFiles( array $fileTypes = array() ) { |
166 | 166 | $list = $this->getCommitList(); |
167 | 167 | $files = array(); |
168 | 168 | foreach ( $list as $file => $status ) { |
— | — | @@ -187,7 +187,7 @@ |
188 | 188 | * |
189 | 189 | * @return String |
190 | 190 | */ |
191 | | - private function getRepoUUID() { |
| 191 | + protected function getRepoUUID() { |
192 | 192 | $output = null; |
193 | 193 | $cmd = "{$this->svnlook} uuid '{$this->repo}'"; |
194 | 194 | exec( $cmd, $output ); |
— | — | @@ -202,7 +202,7 @@ |
203 | 203 | * |
204 | 204 | * @return bool |
205 | 205 | */ |
206 | | - private function testLogMessageLength( $minLength = 1, $regex = '' ) { |
| 206 | + protected function testLogMessageLength( $minLength = 1, $regex = '' ) { |
207 | 207 | $msg = trim( $this->getLogMessage() ); |
208 | 208 | $length = strlen( $msg ); |
209 | 209 | if ( $length < $minLength ) { |
— | — | @@ -223,7 +223,7 @@ |
224 | 224 | * @param $fileTypes array |
225 | 225 | * @return bool|string |
226 | 226 | */ |
227 | | - private function testPHPLint( $fileTypes ) { |
| 227 | + protected function testPHPLint( $fileTypes ) { |
228 | 228 | $output = null; |
229 | 229 | $result = ''; |
230 | 230 | $changedFiles = $this->getChangedFiles( $fileTypes ); |
— | — | @@ -245,7 +245,7 @@ |
246 | 246 | * @param $badUsers array of bad user names |
247 | 247 | * @return bool|string |
248 | 248 | */ |
249 | | - private function testBadUsers( $badUsers ) { |
| 249 | + protected function testBadUsers( $badUsers ) { |
250 | 250 | $ourUser = $this->getAuthor(); |
251 | 251 | if( in_array( $ourUser, $badUsers ) ) { |
252 | 252 | return "Please do not commit as '{$ourUser}', use your real commit name"; |
— | — | @@ -259,7 +259,7 @@ |
260 | 260 | * @param $smtp String SMTP host to use |
261 | 261 | * @todo Make the CR header less hardcoded |
262 | 262 | */ |
263 | | - private function notifyMailingList( $list, $smtp, $header = '' ) { |
| 263 | + protected function notifyMailingList( $list, $smtp, $header = '' ) { |
264 | 264 | $cmd = "{$this->svnnotify} --repos-path \"{$this->repo}\" --revision \"{$this->transaction}\"" |
265 | 265 | . " --to \"{$list}\" --smtp {$smtp} --subject-prefix \"SVN: \"" |
266 | 266 | . " --subject-cx --no-first-line --with-diff --user-domain \"svn.wikimedia.org\"" |
— | — | @@ -272,22 +272,32 @@ |
273 | 273 | * @param $ciaScript String Name of the bot script |
274 | 274 | * @param $acctName String Name of the account with cia.vc |
275 | 275 | */ |
276 | | - private function notifyIRCBot( $ciaScript, $acctName ) { |
| 276 | + protected function notifyIRCBot( $ciaScript, $acctName ) { |
277 | 277 | exec( "{$ciaScript} \"{$this->repo}\" \"{$this->transaction}\" \"{$acctName}\"" ); |
278 | 278 | } |
| 279 | + |
| 280 | + /** |
| 281 | + * Jenkins needs a little more info than a normal ping. So append post data. |
| 282 | + */ |
| 283 | + protected function pingJenkins( $url ) { |
| 284 | + $output = null; |
| 285 | + exec( "{$this->svnlook} changed --revision {$this->transaction} {$this->repo}", $output ); |
| 286 | + $this->pingUrl( $url, implode( "\n", $output ) ); |
| 287 | + } |
279 | 288 | |
280 | 289 | /** |
281 | 290 | * Submit a POST request to the given URL |
282 | 291 | * @param $url String A url to submit revision info to $REV will be replaced |
283 | 292 | * with the revision number, and $UUID will become the repo unique identifier |
284 | 293 | */ |
285 | | - private function pingURL( $url ) { |
| 294 | + protected function pingURL( $url, $postData = '' ) { |
286 | 295 | $url = str_replace( array( '$REV', '$UUID' ), |
287 | 296 | array( $this->transaction, $this->getRepoUUID() ), $url ); |
288 | 297 | $ch = curl_init(); |
289 | 298 | curl_setopt( $ch, CURLOPT_URL,$url ); |
290 | 299 | curl_setopt( $ch, CURLOPT_POST, true ); |
291 | | - curl_setopt( $ch, CURLOPT_POSTFIELDS, '' ); |
| 300 | + curl_setopt( $ch, CURLOPT_POSTFIELDS, $postData ); |
| 301 | + curl_setopt( $ch, CURLOPT_USERAGENT, 'post-commit-cr-hook/0.1' ); |
292 | 302 | curl_exec( $ch ); |
293 | 303 | curl_close( $ch ); |
294 | 304 | } |