You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/05/21 12:16:44 UTC
incubator-ignite git commit: # ignite-456: addJiraComment
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-456 27e7bb12a -> c91674e84
# ignite-456: addJiraComment
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c91674e8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c91674e8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c91674e8
Branch: refs/heads/ignite-456
Commit: c91674e844134b24eed54afc2d2bdc769bbbe016
Parents: 27e7bb1
Author: null <null>
Authored: Thu May 21 13:17:44 2015 +0300
Committer: null <null>
Committed: Thu May 21 13:17:44 2015 +0300
----------------------------------------------------------------------
dev-tools/src/main/groovy/jiraslurp.groovy | 103 +++++++++++++++++-------
1 file changed, 72 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c91674e8/dev-tools/src/main/groovy/jiraslurp.groovy
----------------------------------------------------------------------
diff --git a/dev-tools/src/main/groovy/jiraslurp.groovy b/dev-tools/src/main/groovy/jiraslurp.groovy
index 376034f..1add26e 100644
--- a/dev-tools/src/main/groovy/jiraslurp.groovy
+++ b/dev-tools/src/main/groovy/jiraslurp.groovy
@@ -19,7 +19,8 @@
* attachments to process.
*/
final GIT_REPO = "https://git1-us-west.apache.org/repos/asf/incubator-ignite.git"
-final ATTACHMENT_URL = "https://issues.apache.org/jira/secure/attachment"
+final JIRA_URL = "https://issues.apache.org"
+final ATTACHMENT_URL = "$JIRA_URL/jira/secure/attachment"
final validated_filename = "${System.getProperty("user.home")}/validated-jira.txt"
final LAST_SUCCESSFUL_ARTIFACT = "guestAuth/repository/download/Ignite_PatchValidation_PatchChecker/.lastSuccessful/$validated_filename"
@@ -211,6 +212,44 @@ def getTestBuilds = { ->
}
/**
+ * Util method to send post request.
+ */
+def sendPostRequest = { urlString, user, pwd, postData, contentType ->
+ URL url = new URL(urlString as String);
+
+ HttpURLConnection conn = (HttpURLConnection)url.openConnection();
+
+ String encoded = new sun.misc.BASE64Encoder().encode("$user:$pwd".getBytes());
+
+ conn.setRequestProperty("Authorization", "Basic " + encoded);
+
+ conn.setDoOutput(true);
+ conn.setRequestMethod("POST");
+ conn.setRequestProperty("Content-Type", contentType);
+ conn.setRequestProperty("Content-Length", String.valueOf(postData.length()));
+
+ OutputStream os = conn.getOutputStream();
+ os.write(postData.getBytes());
+ os.flush();
+ os.close();
+
+ conn.connect();
+
+ // Read response.
+ BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+
+ String response = "";
+ String line;
+
+ while ((line = br.readLine()) != null)
+ response += line
+
+ br.close();
+
+ response
+}
+
+/**
* Runs all given test builds to validate last patch from given jira.
*/
def runAllTestBuilds = {builds, jiraNum ->
@@ -240,36 +279,12 @@ def runAllTestBuilds = {builds, jiraNum ->
println "Request: $postData"
- URL url = new URL("http://$tcURL:80/httpAuth/app/rest/buildQueue");
-
- HttpURLConnection conn = (HttpURLConnection)url.openConnection();
-
- String encoded = new sun.misc.BASE64Encoder().encode("$user:$pwd".getBytes());
-
- conn.setRequestProperty("Authorization", "Basic " + encoded);
-
- conn.setDoOutput(true);
- conn.setRequestMethod("POST");
- conn.setRequestProperty("Content-Type", "application/xml");
- conn.setRequestProperty("Content-Length", String.valueOf(postData.length()));
-
- OutputStream os = conn.getOutputStream();
- os.write(postData.getBytes());
- os.flush();
- os.close();
-
- conn.connect();
-
- // Read response.
- BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
-
- String response = "";
- String line;
-
- while ((line = br.readLine()) != null)
- response += line
-
- br.close();
+ def response = sendPostRequest(
+ "http://$tcURL:80/httpAuth/app/rest/buildQueue" as String,
+ user,
+ pwd,
+ postData,
+ "application/xml")
println "Response: $response"
@@ -286,6 +301,32 @@ def runAllTestBuilds = {builds, jiraNum ->
}
/**
+ * Adds comment to jira ticket.
+ */
+def addJiraComment = { jiraNum, comment ->
+ def user = System.getenv('JIRA_USER')
+ def pwd = System.getenv('JIRA_PWD')
+
+ try {
+ println "Comment: $comment"
+
+ def jsonComment = "{\n \"body\": \"${comment}\"\n}";
+
+ def response = sendPostRequest(
+ "$JIRA_URL/jira/rest/api/2/issue/$jiraNum/comment" as String,
+ user,
+ pwd,
+ jsonComment,
+ "application/json")
+
+ println "Response: $response"
+ }
+ catch (Exception e) {
+ e.printStackTrace()
+ }
+}
+
+/**
* Main.
*/
args.each {