ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [14/22] incubator-ignite git commit: ignite-456: get contributors list
Date Tue, 26 May 2015 08:17:05 GMT
ignite-456: get contributors list


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/515d54ca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/515d54ca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/515d54ca

Branch: refs/heads/ignite-471-2
Commit: 515d54caf0ccdc6397255729cb58ddb005aea82d
Parents: 6093619
Author: null <null>
Authored: Mon May 25 16:28:32 2015 +0300
Committer: null <null>
Committed: Mon May 25 16:28:32 2015 +0300

----------------------------------------------------------------------
 dev-tools/slurp.sh                         |   6 -
 dev-tools/src/main/groovy/jiraslurp.groovy | 166 +++++++++++++++---------
 2 files changed, 106 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/515d54ca/dev-tools/slurp.sh
----------------------------------------------------------------------
diff --git a/dev-tools/slurp.sh b/dev-tools/slurp.sh
old mode 100644
new mode 100755
index bf1e91a..12b91f3
--- a/dev-tools/slurp.sh
+++ b/dev-tools/slurp.sh
@@ -51,11 +51,6 @@ TASK_RUNNER_USER='task_runner'
 #
 TASK_RUNNER_PWD=''
 
-#
-# Space separated logins of jira useres which were approved to auto triggering patches. Like
'user1 user2 user3'.
-#
-JIRA_CONTRIBUTORS=''
-
 git fetch
 
 git checkout ${DEFAULT_BRANCH}
@@ -69,6 +64,5 @@ export JIRA_USER=${JIRA_USER}
 export JIRA_PWD=${JIRA_PWD}
 export TASK_RUNNER_PWD=${TASK_RUNNER_PWD}
 export TASK_RUNNER_USER=${TASK_RUNNER_USER}
-export JIRA_CONTRIBUTORS=${JIRA_CONTRIBUTORS}
 
 gradle slurp -b dev-tools/build.gradle

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/515d54ca/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 d70bb32..109dfc0 100644
--- a/dev-tools/src/main/groovy/jiraslurp.groovy
+++ b/dev-tools/src/main/groovy/jiraslurp.groovy
@@ -15,6 +15,10 @@
  * limitations under the License.
  */
 
+/*
+ * Start of util methods.
+ */
+
 def envVariable = { name, defaultVar ->
     def res = System.getenv(name as String)
 
@@ -34,6 +38,79 @@ def envVariableAsList = { name, defaultList ->
 }
 
 /**
+ * Monitors given process and show errors if exist.
+ */
+def checkprocess = { process ->
+    process.waitFor()
+
+    if (process.exitValue() != 0) {
+        println "Return code: " + process.exitValue()
+        println "Errout:\n" + process.err.text
+
+        assert process.exitValue() == 0 || process.exitValue() == 128
+    }
+}
+
+/**
+ * Util method to send http request.
+ */
+def sendHttpRequest = { requestMethod, 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(requestMethod);
+
+    if (postData) {
+        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
+}
+
+/**
+ * Util method to send http POST request.
+ */
+def sendPostRequest = { urlString, user, pwd, postData, contentType ->
+    sendHttpRequest("POST", urlString, user, pwd, postData, contentType);
+}
+
+/**
+ * Util method to send http GET request.
+ */
+def sendGetRequest = { urlString, user, pwd->
+    sendHttpRequest("GET", urlString, user, pwd, null, null);
+}
+
+/*
+ * End of util methods.
+ */
+
+/**
  * Parsing a special filter from Apache Ignite JIRA and picking up latest by ID
  * attachments to process.
  */
@@ -47,10 +124,34 @@ final def JIRA_CMD = System.getProperty('JIRA_COMMAND', 'jira.sh')
 
 // Envariement variables.
 final def TC_PROJECT_NAME = envVariable("PROJECT_NAME", "Ignite")
-
-final def CONTRIBUTORS = envVariableAsList("JIRA_CONTRIBUTORS", [])
 final def TC_BUILD_EXCLUDE_LIST = envVariableAsList("BUILD_ID_EXCLUDES", ["Ignite_RunAllTestBuilds"])
 
+final def JIRA_USER = System.getenv('JIRA_USER')
+final def JIRA_PWD = System.getenv('JIRA_PWD')
+
+final def CONTRIBUTORS = []
+
+def contributors = {
+    if (!CONTRIBUTORS) {
+        def response = sendGetRequest(
+            "$JIRA_URL/jira/rest/api/2/project/12315922/role/10010" as String,
+            JIRA_USER,
+            JIRA_PWD)
+
+        println "Response on contributors request = $response"
+
+        def json = new groovy.json.JsonSlurper().parseText(response)
+
+        json.actors.each {
+            CONTRIBUTORS.add(it.name)
+        }
+
+        println "Contributors list: $CONTRIBUTORS"
+    }
+
+    CONTRIBUTORS
+}
+
 /**
  * Gets jiras for which test tasks were already triggered.
  *
@@ -87,7 +188,7 @@ def getLatestAttachment = { jira ->
         .find {
             def fName = it.@name.toString()
 
-            CONTRIBUTORS.contains(it.@author as String) &&
+            contributors().contains(it.@author as String) &&
                 (fName.endsWith(".patch") || fName.endsWith(".txt") || fName.endsWith(".diff"))
         }
 
@@ -138,20 +239,6 @@ def findAttachments = {
 }
 
 /**
- * Monitors given process and show errors if exist.
- */
-def checkprocess = { process ->
-    process.waitFor()
-
-    if (process.exitValue() != 0) {
-        println "Return code: " + process.exitValue()
-        println "Errout:\n" + process.err.text
-
-        assert process.exitValue() == 0 || process.exitValue() == 128
-    }
-}
-
-/**
  * Applys patch from jira to given git state.
  */
 def applyPatch = { jira, attachementURL ->
@@ -232,50 +319,9 @@ 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
-}
-
-/**
  * 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"
 
@@ -283,8 +329,8 @@ def addJiraComment = { jiraNum, comment ->
 
         def response = sendPostRequest(
             "$JIRA_URL/jira/rest/api/2/issue/$jiraNum/comment" as String,
-            user,
-            pwd,
+            JIRA_USER,
+            JIRA_PWD,
             jsonComment,
             "application/json")
 


Mime
View raw message