Skip to content

Instantly share code, notes, and snippets.

View vikrantyadav11's full-sized avatar
🏠
Working from home

vikrantyadav11

🏠
Working from home
View GitHub Profile
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def projectRoleManager = ComponentAccessor.getComponentOfType(com.atlassian.jira.security.roles.ProjectRoleManager)
def testerRole = projectRoleManager.getProjectRole("contractor")
def project = issue.getProjectObject()
log.warn project
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.atlassian.jira.user.util.UserUtil
UserUtil userUtil = ComponentAccessor.getUserUtil()
def loginManager = ComponentAccessor.getComponentOfType(LoginManager.class)
def groupManager = ComponentAccessor.getGroupManager()
import org.jsoup.Jsoup
def html = "<div class=\"table-wrap\"><table data-layout=\"wide\" data-local-id=\"fa416b5e-c36e-4c93-85b8-ac5652cdecf0\" class=\"confluenceTable\"><colgroup><col style=\"width: 320.0px;\"/><col style=\"width: 320.0px;\"/><col style=\"width: 320.0px;\"/></colgroup><tbody><tr><th class=\"confluenceTh\"><p><strong>Instance</strong></p></th><th class=\"confluenceTh\"><p><strong>Users</strong></p></th><th class=\"confluenceTh\"><p><strong>Projects</strong></p></th></tr><tr><th class=\"confluenceTh\"><p>JSD</p></th><td class=\"confluenceTd\"><p>1000</p></td><td class=\"confluenceTd\"><p>2000</p></td></tr><tr><th class=\"confluenceTh\"><p>Jira Core</p></th><td class=\"confluenceTd\"><p>2000</p></td><td class=\"confluenceTd\"><p>4000</p></td></tr></tbody></table></div><p />"
def table = Jsoup.parse(html).select('table').first()
def rows = table.select('tr')
// find the JSD row
def jsdRow = rows.find { it.select('th').first().text() == 'JSD' }
import org.apache.http.HttpResponse
import org.apache.http.client.HttpClient
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.StringEntity
import org.apache.http.impl.client.HttpClientBuilder
import org.apache.http.util.EntityUtils
import groovy.json.JsonSlurper
def url = 'https://api.openai.com/v1/chat/completions'
def apiKey = 'sk-j4qZQqwS5Lczu3wRgER3TFJbALfxVk99xgsfiJmTlm4'
import org.apache.http.HttpResponse
import org.apache.http.client.HttpClient
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.StringEntity
import org.apache.http.impl.client.HttpClientBuilder
import org.apache.http.util.EntityUtils
def url = 'https://api.openai.com/v1/chat/completions'
def apiKey = 'sk-j4qZQqwS5Lczu3wRgER3T3BlbkFJbALfxVk99xgsmTlm4'
def prompt = 'Hello, ChatGPT!'
import com.atlassian.jira.component.ComponentAccessor
import groovy.sql.Sql
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface
import java.sql.Connection
def delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface)
String helperName = delegator.getGroupHelperName("default")
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
def assignee = issue.getAssignee()
log.warn(assignee)
int customFieldId = 14840
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(customFieldId)
def customFieldValue = issue.getCustomFieldValue(customField)
log.warn(customFieldValue)
import com.atlassian.jira.component.ComponentAccessor
import groovy.sql.Sql
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface
import java.sql.Connection
def delegator = (DelegatorInterface) ComponentAccessor.getComponent(DelegatorInterface)
String helperName = delegator.getGroupHelperName("default")
select cf.cfname from customfield cf where cf.cfname not in (select cf.cfname from customfieldvalue cfv join customfield cf on cfv.customfield = cf.id join jiraissue ji on cfv.issue = ji.id join project p on ji.project = p.id );
import com.atlassian.jira.component.ComponentAccessor
def issuetype = getIssueContext().getIssueType().name
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def test_checkbox = getFieldByName("Test Checkbox")
def customField = customFieldManager.getCustomFieldObject(test_checkbox.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())