You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ho...@apache.org on 2017/07/01 02:19:14 UTC

[incubator-openwhisk-package-jira] branch master updated: Add ASF Headers to source and fix scan errors. (#7)

This is an automated email from the ASF dual-hosted git repository.

houshengbo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-jira.git


The following commit(s) were added to refs/heads/master by this push:
     new 9c051b1  Add ASF Headers to source and fix scan errors. (#7)
9c051b1 is described below

commit 9c051b159a6d7c56770d48abf541b44f09c4f6de
Author: Matt Rutkowski <mr...@us.ibm.com>
AuthorDate: Fri Jun 30 21:19:12 2017 -0500

    Add ASF Headers to source and fix scan errors. (#7)
    
    * Add Travis support and enable scancode.
    
    * Update files to include ASF headers and fix scan errors.
---
 .travis.yml                     | 12 +++++++
 README.md                       | 17 +++++++++-
 src/jirajs/createIssue.js       |  9 ++++--
 src/jiraswift/createIssue.swift | 69 ++++++++++++++++++++++++-----------------
 tests/JiraTests.scala           | 31 +++++++++++++-----
 tools/travis/build.sh           | 12 +++++++
 tools/travis/setup.sh           | 11 +++++++
 7 files changed, 122 insertions(+), 39 deletions(-)

diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..bd647be
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,12 @@
+# A Travis CI configuration file.
+sudo: required
+
+language: scala
+scala:
+   - 2.11.6
+
+before_install:
+  - ./tools/travis/setup.sh
+
+script:
+  - ./tools/travis/build.sh
diff --git a/README.md b/README.md
index 97e6457..df1025e 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,16 @@
-#OpenWhisk Package for Jira 
\ No newline at end of file
+# OpenWhisk Package for Jira
+
+This package includes actions that interact with JIRA software
+software development tool used for issue tracking, and project
+management functions.
+
+For more information on JIRA vist their home page:
+https://www.atlassian.com/software/jira
+
+Specifically, this package includes:
+
+## Actions
+
+* "createIssue"
+    * JavaScript: [createIssue.js](https://github.com/apache/incubator-openwhisk-package-jira/blob/master/src/jirajs/createIssue.js)
+    * Swift: [createIssue.swift](https://github.com/apache/incubator-openwhisk-package-jira/blob/master/src/jiraswift/createIssue.swift)
diff --git a/src/jirajs/createIssue.js b/src/jirajs/createIssue.js
index 1b393f1..7ffcf31 100644
--- a/src/jirajs/createIssue.js
+++ b/src/jirajs/createIssue.js
@@ -1,3 +1,6 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more contributor
+// license agreements; and to You under the Apache License, Version 2.0.
+
 /***********************************************************
 
 Create Issue in Jira.  Issue is encoded as a JSON object
@@ -6,7 +9,7 @@ in the form:
 {
     "fields": {
        "project":
-       { 
+       {
           "key": "TEST"
        },
        "summary": "REST ye merry gentlemen.",
@@ -39,12 +42,12 @@ function main(params) {
   if (!params.issue) {
     return whisk.error("No issue data to create")
   }
-  
+
   var issue = params.issue
   var username = params.jiraUsername
   var password = params.jiraPassword
   var url = 'https://' + username+":" + password + '@'+params.jiraHost+"/rest/api/2/issue/"
-  
+
   console.log("Got url " + url)
 
   var options = {
diff --git a/src/jiraswift/createIssue.swift b/src/jiraswift/createIssue.swift
index 41d4c74..d77da6b 100644
--- a/src/jiraswift/createIssue.swift
+++ b/src/jiraswift/createIssue.swift
@@ -1,8 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 /***********************************************************
- 
+
  Create Issue in Jira.  Issue is encoded as a JSON object
  in the form:
- 
+
  {
  "fields": {
  "project":
@@ -16,13 +33,13 @@
  }
  }
  }
- 
+
  For project, key is the key value assigned to a Jira project, e.g. "MyAwesomeScrumProject"
  may have the key "MYAW"
- 
+
  @param issue the jsonObject representing the issue
  @return response from Jira representing succes or failure
- 
+
  ***********************************************************/
 import Foundation
 import Dispatch
@@ -30,35 +47,35 @@ import KituraNet
 import KituraSys
 
 func main(args: [String:Any]) -> [String:Any] {
-    
+
     guard let username = args["jiraUsername"] as? String else {
         return ["error":"Jira username not set"]
     }
-    
+
     guard let password = args["jiraPassword"] as? String else {
         return ["error": "Jira password not set"]
     }
-    
+
     guard let host = args["jiraHost"] as? String else {
         return ["error": "Jira host not set"]
-        
+
     }
-    
+
     let loginString = ("\(username):\(password)")
-    
+
     let loginData: NSData = loginString.data(using: NSUTF8StringEncoding)!
     let base64LoginString = loginData.base64EncodedString(NSDataBase64EncodingOptions(rawValue: 0))
-    
+
     let headers = ["Content-Type" : "application/json",
                    "Authorization" : "Basic \(base64LoginString)"]
-    
+
     let requestOptions = [ClientRequestOptions.schema("https://"),
                           ClientRequestOptions.method("post"),
                           ClientRequestOptions.hostname(host),
                           ClientRequestOptions.path("/rest/api/2/issue/"),
                           ClientRequestOptions.headers(headers),
                           ClientRequestOptions.disableSSLVerification]
-    
+
     let request = HTTP.request(requestOptions) { response in
         if response != nil {
             do {
@@ -66,13 +83,13 @@ func main(args: [String:Any]) -> [String:Any] {
                 // the response as NSData
                 let jsonData = NSMutableData()
                 try response!.readAllData(into: jsonData)
-                
+
                 let resp = try NSJSONSerialization.jsonObject(with: jsonData, options: [])
                 let r = resp as! [String:Any]
-                
+
                 print("Got response \(r)")
-                
-                
+
+
             } catch {
                 print("error Could not parse a valid JSON response.")
             }
@@ -80,26 +97,22 @@ func main(args: [String:Any]) -> [String:Any] {
             print("error Did not receive a response.")
         }
     }
-    
+
     do {
         #if os(OSX)
             let jsonData = try NSJSONSerialization.data(withJSONObject: args as! [String:AnyObject], options: [])
         #elseif os(Linux)
             let jsonData = try NSJSONSerialization.data(withJSONObject: args.bridge(), options: [])
         #endif
-        
-        
-        
+
+
+
         request.write(from: jsonData)
         request.end()
-        
+
     } catch {
         print("JSON Error \(error)")
     }
-    
+
     return args
 }
-
-
-
-
diff --git a/tests/JiraTests.scala b/tests/JiraTests.scala
index 8de4a26..6944f66 100644
--- a/tests/JiraTests.scala
+++ b/tests/JiraTests.scala
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package catalog
 
 import org.junit.runner.RunWith
@@ -12,26 +29,26 @@ import spray.json.pimpAny
 import common._
 
 @RunWith(classOf[JUnitRunner])
-class grtg  
+class grtg
     extends TestHelpers
     with WskTestHelpers{
-  
+
   implicit val wskprops = WskProps()
   val wsk = new Wsk()
-  
+
   val credentials = TestUtils.getVCAPcredentials("jira")
   val appSecret = credentials.get("appSecret");
   val url = credentials.get("url");
   val appId = url.split("/").last;
   var MessageText = "This is Jira Testing";
-    
+
     behavior of "Jira Package"
-    
+
    it should "Do something" in {
             val name = "/whisk.system/jira/XXX"
              withActivation(wsk.activation,wsk.action.invoke(name, Map("appSecret" -> appSecret, "appId" -> appId, "text" -> MessageText), blocking = true, result = true)){
                 _.fields("response").toString should include ("jira")
              }
     }
-    
-}
\ No newline at end of file
+
+}
diff --git a/tools/travis/build.sh b/tools/travis/build.sh
new file mode 100755
index 0000000..eab9ced
--- /dev/null
+++ b/tools/travis/build.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+set -e
+
+# Build script for Travis-CI.
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+ROOTDIR="$SCRIPTDIR/../.."
+UTILDIR="$ROOTDIR/../incubator-openwhisk-utilities"
+
+# run scancode
+cd $UTILDIR
+scancode/scanCode.py $ROOTDIR
diff --git a/tools/travis/setup.sh b/tools/travis/setup.sh
new file mode 100755
index 0000000..cd20479
--- /dev/null
+++ b/tools/travis/setup.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+SCRIPTDIR=$(cd $(dirname "$0") && pwd)
+HOMEDIR="$SCRIPTDIR/../../../"
+
+# Python
+sudo apt-get -y install python-pip
+
+# clone OpenWhisk repo. in order to run scanCode.py
+cd $HOMEDIR
+git clone https://github.com/apache/incubator-openwhisk-utilities.git

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].