{"id":2533,"date":"2024-03-12T13:07:05","date_gmt":"2024-03-12T17:07:05","guid":{"rendered":"http:\/\/andrewpallant.ca\/wordpress\/?p=2533"},"modified":"2024-03-12T13:22:11","modified_gmt":"2024-03-12T17:22:11","slug":"how-i-use-copilot-to-write-scriptrunner-scripts","status":"publish","type":"post","link":"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/","title":{"rendered":"Copilot to Write ScriptRunner Scripts"},"content":{"rendered":"\n<p>When it comes to scripting, I\u2019ve picked up a few tricks to boost my productivity. First off,\u00a0<strong>time management<\/strong>\u00a0is my secret weapon. I allocate specific chunks of time for different tasks, ensuring I stay focused and efficient. It\u2019s like having a well-organized toolbox\u2014I know exactly which tool to grab when I need it.<\/p>\n\n\n\n<p>Now, let\u2019s talk about my trusty sidekick:&nbsp;<strong>Copilot<\/strong>. Picture this\u2014it\u2019s like having a coding buddy who finishes your sentences. When I sit down to write a script, I engage in a&nbsp;<strong>collaborative thought dance<\/strong>&nbsp;with Copilot. I describe what I want to achieve, and Copilot responds with detailed code snippets. It\u2019s like brainstorming with an AI genie\u2014rub the lamp, state your intent, and voil\u00e0!<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Integration of Copilot<\/strong><\/h2>\n\n\n\n<p>Integrating Copilot into my workflow is smoother than a well-oiled machine. I\u2019ve found that\u00a0<strong>thinking aloud<\/strong>\u00a0is the key. I narrate my intentions, and Copilot listens attentively. It\u2019s like having a co-pilot (pun intended) who understands my context. Copilot adapts to my coding style, preferences, and quirks over time. It\u2019s not just about code; it\u2019s about building a symbiotic relationship.<\/p>\n\n\n\n<ul>\n<li>write a script to run on ScriptRunner using Groovy to get a list of Jira tickets for a given date range<br><\/li>\n\n\n\n<li>rewrite the script using rest API instead of java classes ( <em>this is because Java classes will not work in Jira Cloud<\/em> )<br><\/li>\n\n\n\n<li>amend the script using Jira&#8217;s issue notify API, send an HTML formatted list to a specific user<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Example Output<\/h2>\n\n\n\n<pre class=\"wp-block-code has-vivid-cyan-blue-color has-text-color has-background has-small-font-size\" style=\"background-color:#eeeeee\"><code>import groovyx.net.http.RESTClient\r\n\r\n\/\/ Set your Jira credentials and base URL\r\ndef username = \"your-username\"\r\ndef password = \"your-password\"\r\ndef jiraBaseUrl = \"https:\/\/your-jira-instance.com\"\r\n\r\n\/\/ Set your desired date range (start and end dates)\r\ndef startDate = \"2023-01-01\"\r\ndef endDate = \"2023-01-31\"\r\n\r\n\/\/ Create a JQL query to search for issues created between the specified dates\r\ndef jqlQuery = \"created >= \\\"$startDate\\\" AND created &lt;= \\\"$endDate\\\"\"\r\n\r\n\/\/ Define the Jira REST API endpoint for issue search\r\ndef apiEndpoint = \"${jiraBaseUrl}\/rest\/api\/2\/search\"\r\n\r\n\/\/ Make the REST API request\r\ndef restClient = new RESTClient(apiEndpoint)\r\ndef response = restClient.get(\r\n    path: '',\r\n    query: &#91;jql: jqlQuery, maxResults: 1000], \/\/ Adjust as needed\r\n    auth: &#91;username, password]\r\n)\r\n\r\n\/\/ Parse the response JSON\r\ndef data = response.data\r\n\r\n\/\/ Create an HTML-formatted list of issues\r\ndef htmlList = \"&lt;ul>\"\r\ndata.issues.each { issue ->\r\n    htmlList += \"&lt;li>&lt;a href='${jiraBaseUrl}\/browse\/${issue.key}'>${issue.key}&lt;\/a>: ${issue.fields.summary}&lt;\/li>\"\r\n}\r\nhtmlList += \"&lt;\/ul>\"\r\n\r\n\/\/ Define the recipient's email address\r\ndef recipientEmail = \"user@example.com\"\r\n\r\n\/\/ Send the email using Jira's IssueNotify API\r\ndef issueNotifyApiEndpoint = \"${jiraBaseUrl}\/rest\/api\/2\/issue\/${issue.key}\/notify\"\r\nrestClient.post(\r\n    path: issueNotifyApiEndpoint,\r\n    body: &#91;\r\n        subject: \"Jira Issues Report\",\r\n        textBody: \"Here are the issues created between $startDate and $endDate:\",\r\n        htmlBody: htmlList,\r\n        to: recipientEmail\r\n    ],\r\n    auth: &#91;username, password]\r\n)\r\n\r\n\/\/ Print a success message\r\nprintln \"Email sent to $recipientEmail with the list of issues.\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Challenges and Solutions<\/strong><\/h2>\n\n\n\n<p>\u00a0Now, let\u2019s address the quirks. Copilot occasionally gets a bit too excited, offering\u00a0<strong>complex code structures<\/strong>\u00a0that make my eyebrows raise. But fear not\u2014I wield the editor\u2019s pen. I simplify those suggestions, aligning them with my preferred coding style. It\u2019s a delicate balance between leveraging Copilot\u2019s brilliance and maintaining readability.<\/p>\n\n\n\n<p>And then there\u2019s the matter of&nbsp;<strong>existing patterns<\/strong>. Copilot tends to stick to what it knows, like a creature of habit. But I\u2019m no stranger to adventure. To keep the creative juices flowing, I actively seek fresh approaches beyond the familiar. Copilot is my trusty co-creator, but I\u2019m the artist adding brushstrokes of innovation.<\/p>\n\n\n\n<p>So there you have it\u2014the tale of how Copilot and I waltz through scripts, learning, adapting, and occasionally tripping over our own syntax. It\u2019s a beautiful partnership\u2014one that combines the best of human ingenuity and artificial intelligence.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Finally<\/h2>\n\n\n\n<p>Use the tools that you have to make your scripting easier.   Good luck with your future script automation!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When it comes to scripting, I\u2019ve picked up a few tricks to boost my productivity. First off,\u00a0time management\u00a0is my secret weapon. I allocate specific chunks of time for different tasks, ensuring I stay focused and efficient. It\u2019s like having a well-organized toolbox\u2014I know exactly which tool to grab when I need it. Now, let\u2019s talk &hellip; <a href=\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Copilot to Write ScriptRunner Scripts<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[275,337],"tags":[338,341,339,195,343,340,342],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>Copilot to Write ScriptRunner Scripts - LDNDeveloper<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Copilot to Write ScriptRunner Scripts - LDNDeveloper\" \/>\r\n<meta property=\"og:description\" content=\"When it comes to scripting, I\u2019ve picked up a few tricks to boost my productivity. First off,\u00a0time management\u00a0is my secret weapon. I allocate specific chunks of time for different tasks, ensuring I stay focused and efficient. It\u2019s like having a well-organized toolbox\u2014I know exactly which tool to grab when I need it. Now, let\u2019s talk &hellip; Continue reading Copilot to Write ScriptRunner Scripts\" \/>\r\n<meta property=\"og:url\" content=\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/\" \/>\r\n<meta property=\"og:site_name\" content=\"LDNDeveloper\" \/>\r\n<meta property=\"article:published_time\" content=\"2024-03-12T17:07:05+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2024-03-12T17:22:11+00:00\" \/>\r\n<meta name=\"author\" content=\"ldnDeveloper\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:creator\" content=\"@LdnDeveloper\" \/>\r\n<meta name=\"twitter:site\" content=\"@LdnDeveloper\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ldnDeveloper\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/\"},\"author\":{\"name\":\"ldnDeveloper\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\"},\"headline\":\"Copilot to Write ScriptRunner Scripts\",\"datePublished\":\"2024-03-12T17:07:05+00:00\",\"dateModified\":\"2024-03-12T17:22:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/\"},\"wordCount\":438,\"publisher\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\"},\"keywords\":[\"Copilot\",\"Groovy\",\"Jira\",\"Microsoft\",\"Script Automation\",\"ScriptRunner\",\"Scripts\"],\"articleSection\":[\"AI\",\"Copilot\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/\",\"url\":\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/\",\"name\":\"Copilot to Write ScriptRunner Scripts - LDNDeveloper\",\"isPartOf\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#website\"},\"datePublished\":\"2024-03-12T17:07:05+00:00\",\"dateModified\":\"2024-03-12T17:22:11+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/andrewpallant.ca\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Copilot to Write ScriptRunner Scripts\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#website\",\"url\":\"http:\/\/andrewpallant.ca\/wordpress\/\",\"name\":\"LDNDeveloper\",\"description\":\"Learning, Growing and Sharing.\",\"publisher\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/andrewpallant.ca\/wordpress\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84\",\"name\":\"ldnDeveloper\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg\",\"contentUrl\":\"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg\",\"width\":512,\"height\":512,\"caption\":\"ldnDeveloper\"},\"logo\":{\"@id\":\"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/\"},\"description\":\"Andrew Pallant (@LdnDeveloper) has been a web, database and desktop developer for over 16 years. Andrew has worked on projects that ranged from factory automation to writing business applications. Most recently he has been heavily involved in various forms for ecommerce projects. Over the years Andrew has worn many hats: Project Manager, IT Manager, Lead Developer, Supervisor of Developers and many more - See more at: http:\/\/www.unlatched.com\/#sthash.8DiTkpKy.dpuf\",\"sameAs\":[\"http:\/\/www.andrewpallant.ca\",\"https:\/\/x.com\/LdnDeveloper\"],\"url\":\"http:\/\/andrewpallant.ca\/wordpress\/author\/ldndeveloper\/\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Copilot to Write ScriptRunner Scripts - LDNDeveloper","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/","og_locale":"en_US","og_type":"article","og_title":"Copilot to Write ScriptRunner Scripts - LDNDeveloper","og_description":"When it comes to scripting, I\u2019ve picked up a few tricks to boost my productivity. First off,\u00a0time management\u00a0is my secret weapon. I allocate specific chunks of time for different tasks, ensuring I stay focused and efficient. It\u2019s like having a well-organized toolbox\u2014I know exactly which tool to grab when I need it. Now, let\u2019s talk &hellip; Continue reading Copilot to Write ScriptRunner Scripts","og_url":"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/","og_site_name":"LDNDeveloper","article_published_time":"2024-03-12T17:07:05+00:00","article_modified_time":"2024-03-12T17:22:11+00:00","author":"ldnDeveloper","twitter_card":"summary_large_image","twitter_creator":"@LdnDeveloper","twitter_site":"@LdnDeveloper","twitter_misc":{"Written by":"ldnDeveloper","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/#article","isPartOf":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/"},"author":{"name":"ldnDeveloper","@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84"},"headline":"Copilot to Write ScriptRunner Scripts","datePublished":"2024-03-12T17:07:05+00:00","dateModified":"2024-03-12T17:22:11+00:00","mainEntityOfPage":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/"},"wordCount":438,"publisher":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84"},"keywords":["Copilot","Groovy","Jira","Microsoft","Script Automation","ScriptRunner","Scripts"],"articleSection":["AI","Copilot"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/","url":"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/","name":"Copilot to Write ScriptRunner Scripts - LDNDeveloper","isPartOf":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/#website"},"datePublished":"2024-03-12T17:07:05+00:00","dateModified":"2024-03-12T17:22:11+00:00","breadcrumb":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/andrewpallant.ca\/wordpress\/how-i-use-copilot-to-write-scriptrunner-scripts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/andrewpallant.ca\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Copilot to Write ScriptRunner Scripts"}]},{"@type":"WebSite","@id":"http:\/\/andrewpallant.ca\/wordpress\/#website","url":"http:\/\/andrewpallant.ca\/wordpress\/","name":"LDNDeveloper","description":"Learning, Growing and Sharing.","publisher":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/andrewpallant.ca\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/f6f5bb1ac3e0c5a54a8b5ce35fd67b84","name":"ldnDeveloper","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg","contentUrl":"https:\/\/andrewpallant.ca\/wordpress\/wp-content\/uploads\/2017\/05\/cropped-AAEAAQAAAAAAAAXQAAAAJDQxMGRlMzFjLWM4ODctNDk1NC05M2EyLWE1NDNhNTRiZjVlYw-2.jpg","width":512,"height":512,"caption":"ldnDeveloper"},"logo":{"@id":"http:\/\/andrewpallant.ca\/wordpress\/#\/schema\/person\/image\/"},"description":"Andrew Pallant (@LdnDeveloper) has been a web, database and desktop developer for over 16 years. Andrew has worked on projects that ranged from factory automation to writing business applications. Most recently he has been heavily involved in various forms for ecommerce projects. Over the years Andrew has worn many hats: Project Manager, IT Manager, Lead Developer, Supervisor of Developers and many more - See more at: http:\/\/www.unlatched.com\/#sthash.8DiTkpKy.dpuf","sameAs":["http:\/\/www.andrewpallant.ca","https:\/\/x.com\/LdnDeveloper"],"url":"http:\/\/andrewpallant.ca\/wordpress\/author\/ldndeveloper\/"}]}},"_links":{"self":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts\/2533"}],"collection":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/comments?post=2533"}],"version-history":[{"count":2,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts\/2533\/revisions"}],"predecessor-version":[{"id":2536,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/posts\/2533\/revisions\/2536"}],"wp:attachment":[{"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/media?parent=2533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/categories?post=2533"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/andrewpallant.ca\/wordpress\/wp-json\/wp\/v2\/tags?post=2533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}