Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to create a Service Jelly Script?

Jonathas Knoth September 1, 2011
Hello,
I'm having trouble making my Jelly Script in a periodical service.
Steps I've done:
* I created a service.
Name: SESMT
Class: com.atlassian.jira.jelly.service.JellyService
Delay: 5
Input File: C:\Program Files (x86)\Atlassian\JIRA\atlassian-jira\WEB-INF\classes\Jelly-RH_Estrategico.xml
Output File: C:\Program Files (x86)\Atlassian\JIRA\atlassian-jira\WEB-INF\classes\Out_Jelly_RH_Estrategico.xml
My script works correctly in Jelly Runner.
What should be the type of file to be added to "Input File" and "Output File"?
Where should I put these files?
I must put the full path of my file in the "Input File" and "Output File"?
Below is my Jelly script that works correctly in Jelly Runner!
------------------------------------------------------------------------------------
<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >
      <jira:RunSearchRequest filterid="10101" var="issues" />
      <core:forEach var="issue" items="${issues}">
      <!-- Grab an instance of ComponentManager -->
                <core:invokeStatic className="com.atlassian.jira.ComponentManager" method="getInstance" var="componentManager"/>
 
        <!-- Get the IssueManager from ComponentManager -->
                <core:invoke on="${componentManager}" method="getIssueManager" var="issueManager" />
 
        <!-- Get the MutableIssue from IssueManager -->
                <core:invoke on="${issueManager}" method="getIssueObject" var="issue">
                    <core:arg type="java.lang.String" value="${issue.key}"/>
                </core:invoke>
 
        <!-- Get Custom FieldManager from ComponentManager -->
                <core:invoke on="${componentManager}" method="getCustomFieldManager" var="customFieldManager" />
 
        <!-- Nome Candidato -->
        <!-- Get Custom FieldObject: customFieldObj -->
        <core:invoke on="${customFieldManager}" method="getCustomFieldObject" var="customFieldObj">
                    <core:arg type="java.lang.Long" value="11211"/>
            </core:invoke>
         <!-- Get Custom Field Value: Nome-->
        <core:invoke on="${customFieldObj}" method="getValue" var="nome">
                    <core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issue}"/>
            </core:invoke>
        <!-- Nome CPF-->
        <!-- Get Custom FieldObject: customFieldObj -->
        <core:invoke on="${customFieldManager}" method="getCustomFieldObject" var="customFieldObj">
                    <core:arg type="java.lang.Long" value="11203"/>
            </core:invoke>
         <!-- Get Custom Field Value: CPF-->
        <core:invoke on="${customFieldObj}" method="getValue" var="cpf">
                    <core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issue}"/>
            </core:invoke>
        <!-- Nome DATA-->
        <!-- Get Custom FieldObject: customFieldObj -->
        <core:invoke on="${customFieldManager}" method="getCustomFieldObject" var="customFieldObj">
                    <core:arg type="java.lang.Long" value="11204"/>
            </core:invoke>
         <!-- Get Custom Field Value: Data-->
        <core:invoke on="${customFieldObj}" method="getValue" var="data">
                    <core:arg type="com.atlassian.jira.issue.IssueImpl" value="${issue}"/>
            </core:invoke>
    <jira:CreateIssue project-key="SMT" assignee="user_sesmt" issueType="Novo Colaborador"  summary="Jelly XVIIIY + ${issue.key}" issueKeyVar="issuekey1">
    <jira:AddCustomFieldValue id="customfield_11208" value="  ${nome}" />
    <jira:AddCustomFieldValue id="customfield_11209" value="  ${cpf}" />
    <jira:AddCustomFieldValue id="customfield_11210" value="  ${data}" />
    <jira:AddCustomFieldValue id="customfield_11214" value="  ${issue.key}" />
   </jira:CreateIssue>
    <jira:LinkIssue key="${issue.key}" linkKey="${issuekey1}" linkDesc="SESMT"/>
    <jira:TransitionWorkflow key="${issue.key}" user="admin" workflowAction="41" comment="Pendencia encaminhada para SESMT" />
   </core:forEach>
</JiraJelly>

------------------------------------------------------------------------------------
Tks
Jonathas Knoth
Brazil.

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Edwin Chan
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.
September 1, 2011

My input file is a .txt, but it shouldn't matter because it'll just read it in as text. This is the file that stores your jelly script.

My output file is a .log, but again, it shouldn't matter because it'll just write to it like a text file.

When you run jelly scripts in jelly runner, it uses the logged in user to run the script. When configured as a service, the user must be specified:

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >
<jira:Login username="jdoe" password="mypassword">
MAIN CODE HERE
</jira:Login>
</JiraJelly>

Jonathas Knoth September 1, 2011

I added the tag "jira: Login" in my Jelly but still not running as a service.

I changed the "Input File" and "Output File" to. Txt, and put the tooth (Atlassian \ JIRA \ Atlassian-jira \ WEB-INF \ classes \ Jelly-RH_Estrategico.txt). I ran this as the Jelly Script in Jelly Runner changes, it worked correctly.

But any solution for my problem? No log is being recorded in my Log file

Tks

Edwin Chan
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.
September 1, 2011

Try placing your output file in your home directory (not sure if that'll help, that's just how mine is set up). Other than that, take a look at your JIRA output logs to see what the problem is. You can also set logging for com.atlassian.jira.service to 'INFO' so it's easier to debug.

0 votes
Mehmet Kazgan
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.
April 10, 2014

Hi,

This might be caused by the permissions to execute the files in the folder in the OS>

See here for Linux, someone reported similar issue.

https://answers.atlassian.com/questions/177207/jelly-script-as-a-service-on-linux

0 votes
Václav Nedvěd November 22, 2012

Hi,

I have exactly the same problem. Did you managed it somehow?

Thx

0 votes
Edwin Chan
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.
September 1, 2011

Try placing your output file in your home directory (not sure if that'll help, that's just how mine is set up). Other than that, take a look at your JIRA output logs to see what the problem is. You can also set logging for com.atlassian.jira.service to 'INFO' so it's easier to debug.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events