I am using 2 automation rules for producing sub features for Jira data center when the user clicks on a given transition. 
The first automation rule is reponsible for giving me a summary about the actions that will be executed. Here is my first automation rule: 
Here is the code for the first automation rule:
package SuperFeature
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.bc.project.component.ProjectComponentManager
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
def log = Logger.getLogger('atlassian-jira.log')
List < String > componentList = new ArrayList < String > ()
def projectNames = [ 'WF', 'BF', 'EF', 'YF', 'CLTF']
log.warn("=====MOUNA CAMELIA ISSUE 1:::: "+ issue )
log.warn("=====MOUNA CAMELIA ISSUE:::: "+ issue +" ISSUE COMPONENTS "+issue.getComponents())
if (issue.getComponents().size() == 0) {
issue.update {
String text = "Issue does not have any components\n"
setCustomFieldValue('Execution Summary', text )
}
} else if (issue.getFixVersions().size() == 0) {
issue.update {
String text = "Issue does not have any fix versions\n"
setCustomFieldValue('Execution Summary', text)
}
} else {
int componentSize = issue.getComponents().size()
int generatedIssuesCounter= 0
for (ProjectComponent component: issue.getComponents()) {
String componentName = component.getName()
def shortenedComponentName = componentName.substring(componentName.indexOf("-") + 1)
def projectName = componentName.substring(0, componentName.indexOf("-"))
if(projectNames.contains(projectName)){
def newIssueproject = ComponentAccessor.projectManager.getProjectObjByKey(projectName)
//log.warn("MOUNA CAMELIA found--"+found+"--NEW LIST SIZE: "+newList)
List < ProjectComponent > newList = new ArrayList < > (newIssueproject.getComponents());
def found = newList.any {
it.getName().equals(shortenedComponentName)
}
if (found) {
componentList.add(componentName+" ===> WILL BE GENERATED")
generatedIssuesCounter++
} else{
componentList.add(componentName+" ===> CANNOT BE GENERATED")
}
}
}
issue.update {
String text = "The super feature " + issue + " will be split into " + generatedIssuesCounter + " features, one for each component:\n"
text = text + componentList.join("\n") ;
// Partition a list into list of lists size 3
setCustomFieldValue('Execution Summary', text)
}
}
The second code for my automation rule is responsible for generaring child features depending on the component under question. For example, since we have the componet EF-ADMAF, I would generate a child fetaure that belongs to the project EF and that has the component ADAMF.
Here is the 2nd automation rule: 
Here is the code for my 2nd automation rule:
package SuperFeature
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.bc.project.component.ProjectComponentManager
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
def log = Logger.getLogger('atlassian-jira.log')
List < ProjectComponent > finalComponentList = new ArrayList < ProjectComponent > ()
def projectNames = [ 'WF', 'BF', 'EF', 'YF', 'CLTF']
int componentSize = issue.getComponents().size()
int generatedIssuesCounter= 0
for (ProjectComponent component: issue.getComponents()) {
String componentName = component.getName()
def shortenedComponentName = componentName.substring(componentName.indexOf("-") + 1)
def projectName = componentName.substring(0, componentName.indexOf("-"))
if(projectNames.contains(projectName)){
def newIssueproject = ComponentAccessor.projectManager.getProjectObjByKey(projectName)
List < ProjectComponent > newList = new ArrayList < > (newIssueproject.getComponents());
def found = newList.any {
it.getName().equals(shortenedComponentName)
}
if (found) {
finalComponentList.add(component)
generatedIssuesCounter++
}
}
}
createFeature(issue, finalComponentList)
void createFeature(Issue issue, Collection < ProjectComponent > componentList) {
JiraAuthenticationContext authenticationContext = ComponentAccessor.getJiraAuthenticationContext();
long issueLinkType = 10070 as long
long sequence = 1 as long
long myissueID = issue.getId() as long
// the key of the project under which the version will get created
final String projectKey = "SF"
// the start date - optional
final Date startDate = null
// the release date - optional
final Date releaseDate = null
// a description for the new version - optional
final String description = null
// id of the version to schedule after the given version object - optional
final Long scheduleAfterVersion = null
// true if this is a released version
final boolean released = false
def project = ComponentAccessor.projectManager.getProjectObjByKey(projectKey)
assert project: "Could not find project with key $projectKey"
ProjectComponentManager projectComponentManager = ComponentAccessor.getProjectComponentManager()
for (ProjectComponent component: componentList) {
String componentName = component.getName()
def shortenedComponentName = componentName.substring(componentName.indexOf("-") + 1)
def projectName = componentName.substring(0, componentName.indexOf("-"))
def newIssueproject = ComponentAccessor.projectManager.getProjectObjByKey(projectName)
log.warn("MOUNA CAMELIA HELLO 7 projectName--" + newIssueproject + "--")
List < String > newIssueProjectVersionIDs = new ArrayList < String > ()
newIssueProjectVersionIDs = newIssueproject.getVersions().collect {
it.getName()
}
log.warn("MOUNA CAMELIA HELLO 8 newIssueProjectVersionIDs--" + newIssueProjectVersionIDs + "--")
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10790"); // here replace the ID with ID of your custom field.
def value = issue.getCustomFieldValue(customField);
log.warn("MOUNA CAMELIA HELLO 10 mynewVersions--" + customField + "--")
log.warn("MOUNA CAMELIA 11")
// log.warn("MOUNA CAMELIA ISSUE FIX VERSIONS " + issue.getFixVersions()[0].getClass())
// log.warn("MOUNA CAMELIA NEW ISSUE PROJECT VERSIONS " + newIssueproject.getVersions()[0].getClass())
def matchedVersions = issue.getFixVersions().intersect(newIssueproject.getVersions(), Version.NAME_COMPARATOR)
log.warn("MOUNA CAMELIA MATCHED VERSIONS " + matchedVersions)
// def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10790");// here replace the ID with ID of your custom field.
// def value = issue.getCustomFieldValue(customField) ;
// newissue.setCustomFieldValue(customField, value)
log.warn("MOUNA CAMELIA HELLO 6 newIssueproject " + newIssueproject)
log.warn("MOUNA CAMELIA HELLO 7 component.getDescription() " + component.getDescription())
log.warn("MOUNA CAMELIA HELLO 8 component.getLead() " + component.getLead())
log.warn("MOUNA CAMELIA HELLO 9 component.assigneeType() " + component.assigneeType)
log.warn("MOUNA CAMELIA HELLO 10 component.getProjectId() " + component.getProjectId())
log.warn("MOUNA CAMELIA HELLO 11--" + shortenedComponentName + "--")
ProjectComponent newComponent = projectComponentManager.findByComponentName(newIssueproject.getId(), shortenedComponentName)
def componentArray = new String[1]
componentArray[0]=newComponent.getName()
// newissue.setComponent(mynewComponentList)
// def newIssueCreated = newissue
log.warn(" MOUNA CAMELIA 2 ==========================")
def versionCreator = ComponentAccessor.versionManager.&createVersion.rcurry(startDate, releaseDate, description, newIssueproject.id, scheduleAfterVersion, released)
def mynewVersions = issue.fixVersions.intersect(newIssueproject.versions, Version.NAME_COMPARATOR).collect {
versionCreator it.name + '-Inbox'
}
log.warn("MOUNA CAMELIA 12 " + mynewVersions)
// newissue.setFixVersions(mynewVersions)
Issue newissue = Issues.create(projectName, 'Feature') {
setSummary("["+shortenedComponentName+"] "+issue.getSummary())
setDescription("This feature has been generated as child of a super feature. Please use this text area to add child feature specific information.")
setReporter(issue.getReporter())
setCustomFieldValue(customField.getFieldName(), value)
setFixVersions(mynewVersions as String[])
setComponents (componentArray as String[])
}
log.warn("MOUNA CAMELIA 13")
long newIssueCreatedID = newissue.getId() as long
def labelManager = ComponentAccessor.getComponent(LabelManager)
labelManager.addLabel(authenticationContext.getLoggedInUser(), newIssueCreatedID, "SF-Child", false)
log.warn(" MOUNA CAMELIA 4 ==========================")
log.warn("MOUNA CAMELIA ===== myissueID =====" + myissueID + " =====newissueTypeID =====" + newIssueCreatedID + " =====issueLinkType =====" + issueLinkType + " =====sequence =====" + sequence + " =====authenticationContext.getLoggedInUser() =====" + authenticationContext.getLoggedInUser())
newissue.link(10070, issue)
Collection < ProjectComponent > componentList2 = issue.getComponents()
log.warn("MOUNA CAMELIA COMPONENT LIST 2 " + componentList2)
componentList2.removeAll(issue.getComponents())
log.warn("MOUNA CAMELIA COMPONENT LIST 2 " + componentList2)
projectComponentManager.updateIssueProjectComponents(issue, componentList2)
}
}The problem is that after executing the first 2 automation rules, nothing changes and I need to do a refresh to see the results of the 2 first automation rules. How can I see the effects of the automation rule without hitting the refresh button?
Hi Carl,
Currently, there is no limitation for site-admin on Jira Cloud, it would be great if you could share with us a screenshot of this error.
This problem could also be related to the license. Perhaps the site-admin group is giving license to other products.
Please, go to Site administration > Product access > View configuration and uncheck the group site-admins for all products and let it only on "Jira administration":
After that, please try to add another site-admin and you won't be able to remove yourself, you will need to ask for this new site-admin to remove you.
Hope this helps.
Regards,
Angélica
Hi Angelica,
Would this be the same answer for the Jira Software tool? Currently we have only 1 master Admin, but would like to add another (or at least provide the ability for this person to create Components and push Releases).
Thanks
~Kelly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kelly,
Yes, this answer applies to all Jira Cloud and Confluence too.
The screens on Site administration has changed now, but the idea is the same, remove the site-admin group from the products.
Regards,
Angélica
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.