Scripts doesn't work with jira7 (cf1.getValue(issue).name)

Urszula Forenc March 9, 2018

Hi,

what should we change in the bolded code, to make it work with JIRA 7. We migrate and our old scripts do not work!

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.customfields.manager.OptionsManager

def componentManager = ComponentManager.getInstance()
def customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
def cf1 = customFieldManager.getCustomFieldObjectByName("Department responsible")
def groupManager = ComponentAccessor.getGroupManager()
def currentSecurityLevelId = issue.getSecurityLevel().id
String[] departments = ['department-auto','department-bim','department-korzeniewski','department-ntc','department-pbs','department-siuda','department-wasilewski','department-wolodko','department-zaremba','department-wasilewski-pmo','department-wasilewski-adm','department-pbs-abap','department-pbs-logistic','department-adm','department-poznan','department-hr']

int[] securityIds = [10300,10301,10302,10303,10304,10305,10308, 10306,10307,10400,10401,10402,10403,10500,10501,10502]


def departmentResponsible = cf1.getValue(issue).name

for (def i =0; i<departments.length; i++){

    if (groupManager.isUserInGroup(departmentResponsible, departments[i])){
        if(currentSecurityLevelId == securityIds[i]){
            return
        }
     }
}

for (def i =0; i<departments.length; i++){
            if (groupManager.isUserInGroup(departmentResponsible, departments[i])){
                issue.setSecurityLevelId(securityIds[i])
                return
     }
}

1 answer

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 9, 2018

What is the error?

Urszula Forenc March 9, 2018

Don't see or cant read the file. File groovy.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 9, 2018

You should provide info about the problem with your script, otherwise it is impossible to help you.

Urszula Forenc March 9, 2018

The problem is: when I moved jira to version 7 and put new link to groovy script (in a workflow transition, a postfunction), I get a message "Don't see or cant read the file".

So, I don't know if it is a problem with old script or the other problem.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 9, 2018

That message means you have told Jira to read a script on the disk.  The file with the script in it is either not where you've told it it is, or it is not readable by the user Jira is running as.

It's nothing to do with the content of the script, you need to fix the installation of the script file.

Urszula Forenc March 9, 2018

What does it mean "it is not readable by the user Jira is running as"? How is it possible

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 9, 2018

Again.  Your script is in a file.  Jira cannot read that file from the disk.  Check the permissions and that the file exists.

Urszula Forenc March 11, 2018

Problem was with docker connections. Thank you.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events