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
@vikrantyadav11
vikrantyadav11 / Issue Type Description.groovy
Last active November 1, 2023 16:31
Set Issue Type Description using Behavior Script Runner
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*
def issuetype = getIssueContext().getIssueType().name
if (issuetype.contains("File Transmission Request")) {
getFieldById("issuetype")
.setDescription("<font size=\"2f\">Files must be named correctly as defined in the File Inventory database entry or requests will be returned for review/correction</font>")
@vikrantyadav11
vikrantyadav11 / New Script JIRA issue.groovy
Created May 1, 2021 13:38
Create new jira issue using script runner
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.issueService
def projectManager = ComponentAccessor.projectManager
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def requestTypeValue = "Submit Form 1362" //replace it with the one you want - see note below
def constantsManager = ComponentAccessor.getConstantsManager()
def issueType = constantsManager.getAllIssueTypeObjects().find {it.name.equalsIgnoreCase("New Project Request")}
def issueInputParameters = issueService.newIssueInputParameters()
@vikrantyadav11
vikrantyadav11 / new jira user.groovy
Last active November 1, 2023 16:31
New JIRA User in JIRA Internal Directory
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.user.UserEventType
import com.atlassian.jira.exception.CreateException
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.UserDetails
def uu = ComponentAccessor.userUtil
// START config
@vikrantyadav11
vikrantyadav11 / New JIRA user.groovy
Created May 2, 2021 05:49
New JIRA User in JIRA Default Directory
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.component.ComponentAccessor
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def userService = ComponentAccessor.getComponent(UserService)
UserService.CreateUserRequest createUserRequest = UserService.CreateUserRequest.
withUserDetails(user, "username", "password", "[email protected]", "Test User: user")
UserService.CreateUserValidationResult result = userService.validateCreateUser(createUserRequest)
if(result.isValid())
@vikrantyadav11
vikrantyadav11 / AddUserstoGroup.groovy
Created May 2, 2021 05:57
Add users to a jira group
import com.atlassian.jira.component.ComponentAccessor
// the group you want to remove users from
final String groupName = "jira-users"
// user names of the users to remove
final List<String> usersToRemove = ["john.doe","user_B"]
def userUtil = ComponentAccessor.userUtil
def userManager = ComponentAccessor.userManager
@vikrantyadav11
vikrantyadav11 / Create JIRA User.groovy
Created May 2, 2021 18:18
Create new jira user in JIRA Internal Directory
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.component.ComponentAccessor
// the username of the new user - needs to be lowercase and unique - required
final String userName = "vikrant_kumar"
// The password for the new user - if empty a random password will be generated
final String password = "password"
// The email address for the new user - required
@vikrantyadav11
vikrantyadav11 / Hide Second select list based on first.groovy
Created May 5, 2021 16:12
Hide Second list option based on first select list option
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def list1 = getFieldById(fieldChanged)
def list1Value = list1.value.toString()
def list2 = getFieldByName("List 2")
@vikrantyadav11
vikrantyadav11 / Hide field value on Tranistion Screen.groovy
Created May 6, 2021 04:19
Hide Second value on transition Screen
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
def list1 = getFieldById(fieldChanged)
def list1Value = list1.value.toString()
def list2 = getFieldByName("List 2")
@vikrantyadav11
vikrantyadav11 / Run Select Query.groovy
Created May 12, 2021 09:37
Run SQL query in script console
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.db.DatabaseUtil
import groovy.sql.Sql
import org.ofbiz.core.entity.ConnectionFactory
import org.ofbiz.core.entity.DelegatorInterface
def issueManager = ComponentAccessor.issueManager
@vikrantyadav11
vikrantyadav11 / Defect Denisty.groovy
Last active November 1, 2023 16:30
Defect density using Structure
with Story_Sum = sum{if(issuetype="Story" AND fixVersion = "2021 CapEx - Release 1" ,1)}
:
if(!Story_Sum;"No Story Found";not issuetype;sum
{if((issuetype="Bug" OR issuetype="Customer Bug") AND fixVersion = "2021 CapEx - Release 1",1)}
/ Story_Sum)
if(not issuetype,concat("*{color:red}",sum{if(issuetype="Story",1)}/sum{if(issuetype="Bug",1)},"{color}*"))