๐Ÿ› ๏ธ

Utilize Jira Software

ScriptRunner

[Jobs] ์ž„์ง์› ์ •๋ณด ๋™๊ธฐํ™” ํ”„๋กœ์„ธ์Šค

์‚ฌ๋‚ด API๋ฅผ ํ™œ์šฉํ•ด์„œ, ์ง€๋ผ ๊ณ„์ •์— ์ž„์ง์› ์ •๋ณด๋ฅผ ๋งตํ•‘ํ•ด์ฃผ๋Š” ๋ฐฐ์น˜๋ฅผ Groovy ๋กœ ์ž‘์„ฑ

Source Code

import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.issue.MutableIssue; import com.atlassian.jira.issue.*; import com.atlassian.jira.issue.customfields.*; import com.atlassian.jira.user.UserPropertyManager; import com.atlassian.jira.user.*; import com.atlassian.jira.user.util.UserUtil; import groovy.json.*; import org.apache.http.client.methods.*; import org.apache.http.entity.*; import org.apache.http.impl.client.*; def userPropertyManager = ComponentAccessor.userPropertyManager; UserUtil userUtil = ComponentAccessor.getUserUtil(); def url = "https://xxxxx.com/api/service/findByEmail?email=" int qty = 0 int activeCount = 0; int inactiveCount = 0; int failCount = 0; for(ApplicationUser u in userUtil.getUsers()) { if(!u.isActive()) { inactiveCount++; continue; } else activeCount++; //log.warn(u) //log.warn(u.emailAddress) if(u.emailAddress != null) { def get = new HttpGet(url+u.emailAddress) get.addHeader("host", "xxxxxxx.com") get.addHeader("apikey", "xxxxxxxxxxxxxxxxxx") get.addHeader("content-type", "application/json") def client = HttpClientBuilder.create().build() def response = client.execute(get) if(response.getStatusLine().getStatusCode() == 200) { def bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())) def jsonResponse = bufferedReader.getText() def slurper = new JsonSlurper() def resultMap = slurper.parseText(jsonResponse) if(resultMap["recordset"] != null) { try { resultMap["recordset"]["teamName"] != null ? userPropertyManager.getPropertySet(u).setString('jira.meta.team', resultMap.recordset[0].teamName) : null; resultMap["recordset"]["jobClassCode"] != null ? userPropertyManager.getPropertySet(u).setString('jira.meta.jobClassCode', resultMap.recordset[0].jobClassCode) : null; } catch(Exception e) { failCount++; log.warn("error user:"+u) log.error(e) } } } } } log.warn("active: "+activeCount + "\nfail: "+failCount + "\ninactive: "+inactiveCount);
Groovy
๋ณต์‚ฌ

[Behaviours] ํŠน์ • ํ•„๋“œ ์ œํ•œ ๊ฑธ๊ธฐ

์‚ฌ์šฉ์ž์˜ ํŠน์„ฑ, ํ”„๋กœ์ ํŠธ ๋ณ„, ํ•„๋“œ ์กฐ๊ฑด์— ๋งž๊ฒŒ, ์ง€๋ผ๋‚ด์—์„œ ์ˆ˜์ • ๋˜๋Š” ๋ณผ ์ˆ˜ ์—†๋„๋ก ์„ธ์„ธํ•œ ์กฐ์ • ๊ฐ€๋Šฅ
ํŠน์ • ์‚ฌ์šฉ์ž ์ œ์™ธ
ํŠน์ • ์ปจ๋””์…˜์— ๋งž๊ฒŒ ์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰

[Workflows] ์›Œํฌํ”„๋กœ์šฐ๋ฅผ ์ข€ ๋” ์ƒ์„ธํ•˜๊ฒŒ ์ปจํŠธ๋กค ๊ฐ€๋Šฅ

JSINCLUDER

Javascript ๋ฅผ ์ง€๋ผ์˜ ํŠน์ • ํŽ˜์ด์ง€, ํ”„๋กœ์ ํŠธ์— ์ฃผ์ž…ํ•ด์„œ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ์Œ

์Šคํฌ๋ฆฝํŠธ ์ฃผ์ž…

/* Created by Phil 2020.07.06 WORKING VERSION jsincluder issues in function footer column */ try { let currentIdx = 0, ghxIssuesInEpicTableTRRows = 1, estimate = 0; function timedevide(value) { var week = 0; var day = 0; var hour = 0; hour = parseFloat(value % 40); //์‹œ๊ฐ„ ๊ณ„์‚ฐ day = parseInt(hour / 8); //๋‚  ๊ณ„์‚ฐ week = parseInt((value - hour) / 40); // ์ฃผ ๊ณ„์‚ฐ if (9 < hour < 40) { // ์‹œ๊ฐ„์ด 9~40์‹œ๊ฐ„ ์‚ฌ์ด์ผ ๊ฒฝ์šฐ ๊ณ„์‚ฐ hour = hour - (day * 8) } else if (8 <= hour <= 9) { // ์‹œ๊ฐ„์ด 8~9 ์‹œ๊ฐ„์ผ ๊ฒฝ์šฐ ๊ณ„์‚ฐ hour = hour - 8 } return { // ๊ฒฐ๊ณผ๊ฐ’ ๋ฆฌํ„ด h: +hour.toFixed(4), d: +day.toFixed(4), w: +week.toFixed(4) } } const loopForever = () => { if (currentIdx < ghxIssuesInEpicTableTRRows) { // console.log('currentIdx: '+currentIdx+' ghxIssuesInEpicTableTRRows: '+ghxIssuesInEpicTableTRRows); setTimeout(loopForever, 500); // console.log('loop'); } else { // console.log('currentIdx: '+currentIdx+' ghxIssuesInEpicTableTRRows: '+ghxIssuesInEpicTableTRRows); var actions2 = AJS.$('#ghx-issues-in-epic-table tbody'); AJS.$(actions2).before('<thead><tr class="issuerow"><th></th><th>Key</th><th>Summary</th><th></th><th>Status</th><th>Assignee</th><th>Due Date</th><th>Original<br/>Estimate</th><th></th></tr></thead>'); AJS.$(actions2).after('<tfoot><tr class="issuerow"><td></td><td></td><td></td><td></td><td>์ด๊ณต์ˆ˜</td><td>' + +(estimate / 160).toFixed(4) + '</td><td>Sum</td><td>' + timedevide(estimate).w + "Week " + timedevide(estimate).d + "Day " + timedevide(estimate).h + "Hour " + '</td><td></td></tr></tfoot>'); } } AJS.$(document).ready(function () { try { //Updated 2020.07.06 by Phil let rows = AJS.$('#ghx-issues-in-epic-table tr'); ghxIssuesInEpicTableTRRows = rows.length; // console.log("total row: "+ghxIssuesInEpicTableTRRows); if (rows.length > 0) { loopForever(); } rows.each(function () { // ์—ฌ๊ธฐ์— ์žˆ์œผ๋ฉด getJson ๋ณด๋‹ค ๋จผ์ € ์ฒ˜๋ฆฌ๋จ // currentIdx = currentIdx + 1; var row = this; var value; var issueKey = AJS.$(this).attr("data-issuekey"); if (issueKey) { AJS.$.getJSON(AJS.contextPath() + '/rest/api/latest/issue/' + issueKey, function (data) { value = 0; if (data.fields.aggregatetimeoriginalestimate) { value = data.fields.aggregatetimeoriginalestimate / 3600; estimate = estimate + value; } else { value = 0; } var actions = AJS.$(row).find('td.issue_actions'); duedate = data.fields.duedate; AJS.$(actions).before('<td class="nav">' + duedate + '</td>'); AJS.$(actions).before('<td class="nav">' + timedevide(value).w + "Week " + timedevide(value).d + "Day " + timedevide(value).h + "Hour " + '</td>'); // console.log("index: "+currentIdx + " value:" +value); currentIdx = currentIdx + 1; }); } else { // console.log(AJS.$(this)); currentIdx = currentIdx + 1; } // console.log('estimate: '+estimate); }); } catch (error1) { alert(`๋‹ค์Œ๊ณผ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค: ${error1.name}: ${error1.message}`); // console.log(error1); } }); } catch (error) { alert(`๋‹ค์Œ๊ณผ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค: ${error.name}: ${error.message}`); // console.log(error); }
JavaScript
๋ณต์‚ฌ