├── .gitignore ├── LICENSE.md ├── README.md └── jira-create-issue ├── LICENSE.md ├── README.md └── code.gs /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 thedataplumber 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Description 2 | This is a collection of Google Scripts I've used or created to perform various functions. Any questions/issues, drop me a message or tweet [@jodygajic](https://twitter.com/jodygajic). 3 | 4 | # Contents 5 | 1. JIRA Create Issue 6 | 2. ... 7 | 8 | # JIRA Create Issue 9 | A Google Form uses the [JIRA REST API](https://docs.atlassian.com/jira/REST/latest/), via the associated spreadsheet, to create a new issue. 10 | 11 | The script sends an email to the issue creator, providing the ticket reference, and link to the JIRA system. There are lots of comments in the code, which should be enough to work from. 12 | 13 | I've blogged about this script, and added some more context and a short how to here: 14 | [Use a Google Form To Create JIRA Issues With The REST API](https://thedataplumber.net/use-a-google-form-to-create-jira-issues-with-the-rest-api-b7fe131de092). 15 | 16 | ## Caveats 17 | The script was made for an enterprise that uses Google apps; the Google form requires that the user is logged into the company domain (so email address is automatically captured). Some modifications may be required for your use case! 18 | -------------------------------------------------------------------------------- /jira-create-issue/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 thedataplumber 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /jira-create-issue/README.md: -------------------------------------------------------------------------------- 1 | # Description 2 | A Google Form uses the [JIRA REST API](https://docs.atlassian.com/jira/REST/latest/), via the associated spreadsheet, to create a new issue. 3 | 4 | The script sends an email to the issue creator, providing the ticket reference, and link to the JIRA system. There are lots of comments in the code, which should be enough to work from. 5 | 6 | Any questions/issues, drop me a message or tweet [@jodygajic](https://twitter.com/jodygajic). 7 | 8 | ## Caveats 9 | The script was made for an enterprise that uses Google apps; the Google form requires that the user is logged into the company domain (so email address is automatically captured). Some modifications may be required for your use case! 10 | 11 | # More Information 12 | I've blogged about this script, and added some more context and a short how to here: 13 | [Use a Google Form To Create JIRA Issues With The REST API](https://thedataplumber.net/use-a-google-form-to-create-jira-issues-with-the-rest-api-b7fe131de092) 14 | -------------------------------------------------------------------------------- /jira-create-issue/code.gs: -------------------------------------------------------------------------------- 1 | // 2 | // This script takes the user inputs from the Google Form, and will create a JIRA issue when the form is submitted via the REST API 3 | // Takes user input info, and passes it into an event parameter "e" 4 | // 5 | function createIssue(e){ 6 | // 7 | // Assign variables to the form data submitted by the requestor from the spreasheet associated with the Google form. 8 | // NOTE: Update the [n] to the cell value in your spreadsheet. 9 | // 10 | var requesterEmail = e.values[1]; 11 | var summary = e.values[2]; 12 | var description = e.values[3]; 13 | // 14 | // The dueDate variable requires a formating update in order that JIRA accepts it 15 | // Date format becomes YYYY-MM-DD, and is called later in the data posted to the API 16 | // 17 | var dueDate = e.values[4]; 18 | var formattedDate = Utilities.formatDate(new Date(dueDate), "GMT", "yyyy-MM-dd"); 19 | // 20 | // Contact names 21 | // 22 | var businessSponsor = e.values[5]; 23 | var technicalContact = e.values[6]; 24 | var docLinks = e.values[7]; 25 | // 26 | // Assign variable to your instance JIRA API URL 27 | // 28 | var url = "https://.atlassian.net/rest/api/latest/issue"; 29 | // 30 | // The POST data for the JIRA API call 31 | // 32 | var data = 33 | { 34 | "fields": { 35 | "project":{ 36 | "key": "" 37 | }, 38 | "priority": { 39 | "name": "Minor" 40 | }, 41 | "duedate": formattedDate, 42 | "summary": summary, 43 | "description": description, 44 | // 45 | // The following custom fields are for the various strings and are simple text fields in JIRA 46 | // You can find all the custom fields by looking here: https://.atlassian.net/rest/api/latest/field/ 47 | // 48 | "customfield_14902": businessSponsor, 49 | "customfield_16100": technicalContact, 50 | "customfield_10216": requesterEmail, 51 | "customfield_14308": docLinks, 52 | // 53 | // All tickets are categorised as Tasks, and are not changed by the form submission. 54 | // 55 | "issuetype":{ 56 | "name": "Task" 57 | } 58 | } 59 | }; 60 | // 61 | // Turn all the post data into a JSON string to be send to the API 62 | // 63 | var payload = JSON.stringify(data); 64 | // 65 | // POST header information, including authorization information. 66 | // This API call is linked to an account in JIRA, and follows the Basic Authentication method ("username:password" are Base64 encoded) 67 | // 68 | var headers = 69 | { 70 | "content-type": "application/json", 71 | "Accept": "application/json", 72 | "authorization": "Basic " 73 | }; 74 | 75 | // 76 | // A final few options to complete the JSON string 77 | // 78 | var options = 79 | { 80 | "content-type": "application/json", 81 | "method": "POST", 82 | "headers": headers, 83 | "payload": payload 84 | }; 85 | 86 | // 87 | // Make the HTTP call to the JIRA API 88 | // 89 | var response = UrlFetchApp.fetch(url, options); 90 | Logger.log(response.getContentText()); 91 | // 92 | // Parse the JSON response to use the Issue Key returned by the API in the email 93 | // 94 | var dataAll = JSON.parse(response.getContentText()); 95 | var issueKey = dataAll.key 96 | Logger.log(dataAll) 97 | // 98 | // Assign variables for the email reposnse 99 | // 100 | var myMailbox = "noreply@nodomain.com" 101 | var emailSubject = "Your request no. " + issueKey + " has been created"; 102 | var emailBody = "Thank you for your ticket submission." + "\n\n" + 103 | "Your request has been created, your reference is " + issueKey + " which can be accessed via the following link to the JIRA system:" + "\n\n" + 104 | "https://.atlassian.net/browse/"+ issueKey + "\n\n" + 105 | "We will be in touch soon to discuss your ticket submission. " + 106 | // 107 | // Send an email to the requestor 108 | // 109 | MailApp.sendEmail(requesterEmail, emailSubject, emailBody, { 110 | name: "" 111 | }) 112 | } 113 | --------------------------------------------------------------------------------