Why ComponentManager is not defined ?

Manuel Campomanes February 9, 2012

Hello,

I installed "Quisapps Jira Scripting Suite" plugin on my Jira, I need to execute jython script on workflow transition so I use Jython post-function script.

I try to edit a customfield so I do that :

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField

customFieldManager = ComponentManager.getInstance().getCustomFieldManager()
customField = customFieldManager.getCustomFieldObject("customfield_10008")

issue.setCustomFieldValue(customField, "15/02/2012 10:02")

But I have an error cause by the ComponentManager, he's not defined (name 'ComponentManager' is not defined)

I search information about this error but I failed. I hope you can help me.

Cheers,

Manuel.

6 answers

1 accepted

0 votes
Answer accepted
Manuel Campomanes February 9, 2012

there was a problem with the import.

Solution >

from com.atlassian.jira import ComponentManager

Manuel Campomanes February 9, 2012
Here is the solution to set a customfield type Date in a post-function (python) :

from com.atlassian.jira import ComponentManager import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import datetime customFieldManager = ComponentManager.getInstance().getCustomFieldManager() customField = customFieldManager.getCustomFieldObject("customfield_10008") issue.setCustomFieldValue(customField, datetime.datetime(2012, 5, 29, 10, 30, 45))

Check datetime documentation for more options.

1 vote
Stein Jakob Modalsli June 24, 2012

A little late answer, but in case someone else has the same problem:

I also had this problem when trying to edit an old plugin.

The reason for this is that, by default, "jira-core" has been excluded as an dependency in pom.xml.
Remove the <!-- and --> in the code below to include "jira-core".
This solved my problems.

<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<!--
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
-->

0 votes
jeyaluxshan October 25, 2018

I am new to python scripting. When i run, i am getting following import error.

ImportError: No module named com.atlassian.jira.component

How can i fix this? where can i download com.atlassian.jira.component module and install.

Any suggestions much appreciated.

Regards

Jey

0 votes
JamieA
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.
February 9, 2012

> there was a problem with the import

that's why i thought it didn't look like python.

0 votes
Manuel Campomanes February 9, 2012

I take a look about this : https://studio.plugins.atlassian.com/wiki/display/JSS/Scripting+Samples

It's a copy modified.

0 votes
JamieA
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.
February 9, 2012

Did you write that yourself, or copy it from somewhere? That doesn't even look like jython code.

Suggest an answer

Log in or Sign up to answer