Skip to end of metadata
Go to start of metadata

Redirection Notice

Icon
This page will redirect to https://confluence.atlassian.com/x/ewISCw in about 2 seconds.

 

  • No labels

40 Comments

  1. Wouldn't it be nice to have a place here where to place User Contributed Jelly Scripts? I found some in the forum but there is still a lot of white space to be filled. Well, perhaps the easiest solution is what I am doing now: Here is one my examples as comment:

    Bulk Change Comment Visibility

    Mind that I set some loggings to level warn just to make them appear in the log without further configuration. Actually I don't know how to configure logging to make it more verbose for jelly scripts.

    1. Hi, How do you debug your jelly scripts? Where does the warning or debug strings get logged to? I search entire JIRA install directory and could not find any file containing the output. Should it be logged to stdout_*.log files. Do I need to restart JIRA to see the output. That would make iteration time unbearable.

      Many Thanks!

      ____

      <JiraJelly
      xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:log="jelly:log">
      <log:debug> Hello this is my first Jelly Script! </log:debug>
      <log:warn> Warning this is Jelly!</log:warn>
      </JiraJelly>

    2. To enable Debug Output:

      1. Edit atlassian-jira/WEB-INF/classes/log4j.properties
      2. In 3.7 and above: locate the section:log4j.category.jelly = WARN, console, filelog
        log4j.additivity.jelly = false

      To enable Debug Output:

      #####################################################
      # LOGGING LEVELS
      #####################################################
      # To turn more verbose logging on - change "WARN" to "DEBUG"
      log4j.rootLogger=DEBUG, console, errorlog, filelog

      #####################################################

      log4j.category.jelly = DEBUG, console, filelog
      log4j.additivity.jelly = fal

      1. Anonymous

        Could you explain more detail where to view debug message and how to enable it.

        Thanks

  2. Bulk Update Issue Security Levels

    The following script will update the security levels of the issues returned by a filter. The script requires two arguments:

    • issueFilter – the id of the filter which returns the issues to process
      The ID can be found out e. g. on the Manage Filters screen. Just extract the requestId from the filter link.
    • targetSecurityLevelId – the id of the security level to set
      To get the id go to Administration / Issue Security Schemes / Operations: Security Levels. Then analyze the URL for the operations. The parameter security is what you are searching for.

    The script does not check for any errors, e. g. if the security level is valid in the given context of the issue. To go into detail here, have a look at the Forum (http://forums.atlassian.com/thread.jspa?messageID=257223939).

    One last thing: On overviews (such as filter results) the issues will still appear with the old security level. Re-Indexing is your friend here.

    1. Hi Mark,

      your script is incredebly useful (for my Jira implementation) but as you say the issue is that there is no automatic re-index so it becomes almost unuseful (I've done a test, made the update during the afternoon and checked it the day after, the update is still not visible in filters, so there is no midnight re-index as said here).

      I know that you can launch the re-index process from Jira but I didn't find a way to make it running periodically (let's say every night at midnight) this would make your script much more useful. Any idea how to make the re-index running as a service? 

  3. Creating A Subtask

    Here is a jelly script that will create a subtask without the addition or modification to the Jira code base.
    Special thanks to Mark for his example subtask jelly tag that provided the necessary insight into the Manager API.

  4. I use this jelly script in order to close all the issues resolved and not apdated by the customer

    <JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log" >
    <jira:Login username="admin" password="admin">
        <log:info>Running Close issues service</log:info>
        <!- Properties for the script ->
        <core:set var="comment">This issue has not been updated for 8 business days and will be Closed.
       
    If this issue has not been completed please reopen this issue and we will do our best to help you as soon as we can.
       
    Thank you,
       
      The Atlassian Support Team</core:set>
        <core:set var="workflowStep" value="3" />
        <core:set var="workflowUser" value="admin" />
        <core:set var="filter7Days" value="10000" />

        <!- Run the SearchRequestFilter ->

        <jira:RunSearchRequest filterid="$

    Unknown macro: {filter7Days}

    " var="issues" />


       
        <!- Iterate over the issues ->

        <core:forEach var="issue" items="$

    Unknown macro: {issues}

    ">


            <log:warn>Closing inactive issue $

    Unknown macro: {issue.key}

    </log:warn>


            <jira:TransitionWorkflow key="$

    Unknown macro: {issue.key}

    " user="$

    Unknown macro: {workflowUser}

    " workflowAction="$

    Unknown macro: {workflowStep}

    " comment="$

    Unknown macro: {comment}

    " resolution="$(fixed)"/>


        </core:forEach>
    </jira:Login>
    </JiraJelly>

     How can I set the delay to 7, 8 or 10 days? is it in the filter I'll configure? (in the filter there's no way to choose a delay)

    1. Hi Amina,

      I must admit I was surprised myself that this is not mentioned on the Jelly Escalation page. It's in the administration section of JIRA where you can adjust this:

      1. Administration
      2. System >> Services
      3. Add a service:
        1. Name My Escalation Task
        2. Built-in Services: Run Jelly script
        3. Delay: in minutes
        4. Press Add Service button
        5. Input File: The Jelly script to run. Must be located on the server.
        6. Output File: Can be empty.
        7. Delay: Hm, can be entered/altered here again.
        8. Press Update
  5. Thank you Mark, for your answer but I'll give an example to explain my problem:

    I have some issues waiting for the customer validation, if these issues are inactive for 8 days I want to change there statut into closed

    All the issues are not created or modified at the same date so a service wich will turn every 8 days would change all the "waiting validation" statuts even the issues resolved since the day before...

    So what I need is to have a filter that takes all the issues with "waiting validation" statut 8 days before

    The service can turn every day

    Perhaps what you explained to me Mark is what I should do but ???

  6. I have a problem with my script below. I have this error in the outputFile:

    null:-1:-1: <null> Could not parse Jelly script

    1. I've found the same error as amina, when in the Jelly Script there are tilde, and other extrange characters.

  7. Anonymous

    can you post an example of how to use core:if tag. i can't find any useful examples. how to compare two variables, for example.t

  8. A simple jelly script for updating custom field on issues. I create custom filed Rating of type Number Field. This script increment Rating(id=10133) on all issues from filterid=11711

    1. Hi,

      How do I update required custom field/s while doing jira:TransitionWorkflow?

      There is no parameter for custom field in jira:TransitionWorkflow

      http://confluence.atlassian.com/display/JIRA/Jelly+Tags?showComments=true&showCommentArea=true#addcomment

    2. Hi,

      I have a problem. I have executed the script by updating a "Multicheck box" custom field that has three options:

      • Option 1
      • Option 2
      • Option 3

      I have created 3 tickets with the field set to "Option 1"

      Running the script I would change the field value to "Option 3". The script run successfully and if I check the ticket it has the value updated to "Option 3". The problem is that the changes happened only at the view screen because if I search for all the tickets with "Option 3" the result is zero. If I search for tickets with "Option 1" the result is 3.

      The issue navigator shows in the appropriated column the value "Option 3" but the query was done by searching for "Option 1". So something was not updated.

      Any suggestion? It could be related to re-indexing?

      1. Yes, I have verified by myself that it is necessary to re-index the application. This is a problem because this functionality cannot be used for update in near real time. Re-indexing usually takes a log time.

    3. Hi,

      I have another problem.I have a custom filed named "Potential Security Incident". The script doesn't work if the name contains spaces. If I modify the name to "PotentialSecurityIncident" without spaces, it works. I tried to use the ascii code (Potential Security Incident) without success.

      Could you help me please?

    4. Hi Alexander

      I would like to use the same script but instead of changing the custom field of number type i want to change the Date time field and increment it by "X" hours. Let me know how it can be achieved. It will be a great help.

    5. Here, another version with few lines using the amazing WorkflowUtils plugin.

      Particularly, we use to update SLA fields daily and produce simple gadgets, like pie charts.

      Note: use with careful in huge databases.

    6. hello

      i was using the above script for editing issue, but now after upgrading to 4.3 i got this error

      java.lang.InstantiationException: com.atlassian.jira.issue.fields.DefaultFieldManager
              at java.lang.Class.newInstance0(Class.java:340)
              at java.lang.Class.newInstance(Class.java:308)
              at org.apache.commons.jelly.tags.core.NewTag.doTag(NewTag.java:80)
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
              at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
              at org.apache.commons.jelly.tags.core.ForEachTag.doTag(ForEachTag.java:150)
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
              at com.atlassian.jira.jelly.tag.login.Login.doTag(Login.java:127)
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
              at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)
              at org.apache.commons.jelly.impl.StaticTag.doTag(StaticTag.java:65)
              at org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:102)
              at com.atlassian.jira.web.action.util.JellyRunner.doExecute(JellyRunner.java:96)
              at webwork.action.ActionSupport.execute(ActionSupport.java:165)
              at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:74)
              at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:39)
              at webwork.interceptor.NestedInterceptorChain.proceed(NestedInterceptorChain.java:31)
              at webwork.interceptor.ChainedInterceptor.intercept(ChainedInterceptor.java:16)
              at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:35)
              at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:205)
              at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:143)
              at com.atlassian.jira.web.dispatcher.JiraWebworkActionDispatcher.service(JiraWebworkActionDispatcher.java:151)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.atlassian.jira.web.filters.JiraLastFilter.doFilter(JiraLastFilter.java:81)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.atlassian.core.filters.HeaderSanitisingFilter.doFilter(HeaderSanitisingFilter.java:44)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
              at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)
              at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:25)
              at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)
              at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
              at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)
              at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      java.lang.InstantiationException: com.atlassian.jira.issue.fields.DefaultFieldManager

              at java.lang.Class.newInstance0(Class.java:340)

              at java.lang.Class.newInstance(Class.java:308)

              at org.apache.commons.jelly.tags.core.NewTag.doTag(NewTag.java:80)

              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)

              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)

              at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)

              at org.apache.commons.jelly.tags.core.ForEachTag.doTag(ForEachTag.java:150)

              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)

              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)

              at com.atlassian.jira.jelly.tag.login.Login.doTag(Login.java:127)

              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:247)

              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)

              at org.apache.commons.jelly.TagSupport.invokeBody(TagSupport.java:186)

              at org.apache.commons.jelly.impl.StaticTag.doTag(StaticTag.java:65)

              at org.apache.commons.jelly.impl.StaticTagScript.run(StaticTagScript.java:102)

              at com.atlassian.jira.web.action.util.JellyRunner.doExecute(JellyRunner.java:96)

              at webwork.action.ActionSupport.execute(ActionSupport.java:165)

              at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:74)

              at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:39)

              at webwork.interceptor.NestedInterceptorChain.proceed(NestedInterceptorChain.java:31)

              at webwork.interceptor.ChainedInterceptor.intercept(ChainedInterceptor.java:16)

              at webwork.interceptor.DefaultInterceptorChain.proceed(DefaultInterceptorChain.java:35)

              at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:205)

              at webwork.dispatcher.GenericDispatcher.executeAction(GenericDispatcher.java:143)

              at com.atlassian.jira.web.dispatcher.JiraWebworkActionDispatcher.service(JiraWebworkActionDispatcher.java:151)

              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at com.atlassian.jira.web.filters.JiraLastFilter.doFilter(JiraLastFilter.java:81)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at com.atlassian.core.filters.HeaderSanitisingFilter.doFilter(HeaderSanitisingFilter.java:44)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

              at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)

              at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:66)

              at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:25)

              at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:74)

              at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)

              at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:77)

              at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:63)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

  9. How to get ChangeHistory of an issue through Jelly Script.

    1. I'm getting it in this way:

      1. Thanks for your valuable code.I am really glade to see your reply...

        one more query-

        how to set ChangeHistory in JIRA using Jelly Script.

        Thanks again :)

        1. You meen, that you want to change old history? I think that it is not possible to change old history via Jira API. But in jelly you can work with jira database and change all what you need in db. Use sql tag for it.  Here you can find more examples.

          1. Thanks for you quick response.

            Actually i am updating custumfield value using Jellly Script and would like to set Change History for that change.

            Means: Suppose we have one Text field and Using Jelly Script i am replacing old value with some new value so i want to set ChangeHistory for the same.

            Thanks,

            Dharmendra

            1. Sorry, but i don't now how to reflect custom field changes in history.

  10. Updating Issue Using Excel File
    1. Hello,

      when I try to update personal customfield in a jelly script using this method, I have this error : No such accessible constructor on object: com.atlassian.jira.issue.ModifiedValue

      Anyone has an idea?

      ----------------------

      I found my answer : there are two arguments for this method : oldValue and newValue but it seems that the oldValue is useless. What is the point of using the oldValue argument?

      Thanks.

      1. Hi Antoine,ModifiedValue class has two method as given below, for retrieving of
        these values it include two arguments in the constructor.

        ModifiedValue(Object oldValue,Object newValue)          

        Object

        getNewValue()
                  

        Object

        getOldValue()

        by the help of old value and new value, we can set change history of that particular custom fiels.

        I did not go through ModifiedValue class implementation, may be my observation is

        wrong.

        Please keep in touch and let me know once you get something.

        Thanks,

        Dharmendra

  11. Introduction:

     JIRA has Clone feature, which create exact copy of the issue with different issue id/key and everything will be same as parent issue has.

    For clone issues, user can change only summary of the issue at the time of cloning and other custom field's value will remains same.

    Sometime, some custom field's value is not required for the clone issue like version/patch number and user want to edit(null) those custom field's value. To over come this issue, user have to go through each and every issues and edit value manually.

    Code Description:

    To over come this issue, i have written Jelly Script, which is finding clone issues from the saved filter (You have to create filter for this) and updating the custom field's value. Please find the flow as given below -

    1. Jelly Script will check whether it is a clone issue or not.

    2. If it is a clone issues, it will check change history for that particular custom field and will check someone changed the value or not.

    3. If someone changed the value, it will skip this issue and will proceed for next issue.

    4. If no change history is there for that particular custom field, it will change the field's value as per user requirement and will update the issue.

    Please find the code below in which i am updating one custom field as Program management target, user can update as many field as he want -

    Please let me know, if you face any problem.

    1. Hi, I'm experiencing the following error

      <JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib" xmlns:core="jelly:core" xmlns:log="jelly:log">
      Total Number Of Issue ::88
      
      org.apache.commons.jelly.JellyTagException: null:50:0: <core:invoke> No such accessible method: getCustomFieldValue() on object: com.atlassian.jira.issue.IssueImpl
      </JiraJelly> 

      My environment is Jira 3.13.5 Enterprise

  12. Updating Fix Version / Updating issues when the .store() method does not work.

    I wanted a Jelly script to synchronize the Fix Version on an Issue to all of it's Subtasks. That can be accomplished using information gathered on this page, for the most part. But when I came to run it, it just didn't save.

    After digging through the forums I found some similar issues with saving issues when the component had been updated, so it's possible that you might see this trying to save fields other than the 'simple' values. This thread is not Jelly-related, but seemed to point to using the ActionDispatcher directlyhttp://forums.atlassian.com/thread.jspa?messageID=257315848?

    Below is a sample script that uses this to set the parent FixVersion on all subtasks.

    Works for me on 3.11

    1. Alastair,

      Thanks for posting this. I was having a hard time getting updates on an issue with Jelly to work before I found your example. Much appreciated.

      ~Matt

  13. Hi, Guys:

    I'm assigned the task to merging two jira instance using jelly script. I just wanna know if I can run

    jelly script to get another jira instance's data?

    For example, I have two jira instances A and B in different server and I want to merge data of jira A

    to B. In the jelly runner page of B, can I write some jelly script to get all the projects from A then

    create these projects in B? If not, how to achieve it?

    1. Hi, you can use this jira-to-jira script based on Jelly.

  14. Extending on Alistair King's example, here's a more involved example.  For us, we have an ecommerce website which gets weekly production moves.  We automate management of the site's versions with a Jelly script.  This script automatically creates the project version for this week's update (if necessary; releases are done on Saturday), and migrates any closed tickets fixed in the "Maintenance" version to that new version.  It gets the tickets from a report which for us only includes tickets in the "closed" status.  This way a ticket can be reported against Maintenance, and it will remain there until closed (closure indicating the ticket is ready to promote to production).  I designed it to work for a filter which returns issues from multiple projects (assuming that they all use the format for their weekly update tickets), which has the added benefit of not having to code in any additional information about the project.

    I realize this is pretty specific to our business processes, so I don't think this script would work wholesale for anyone else, but I stumbled through a lot of these things with trial and error (there seem to be very few Jelly examples out there).  I figured more working examples could be of benefit to other people (particularly with respect to doing things like creating a Collection). 

    Thanks to Alistair for your example on how to save - I thought I was losing my mind until I found your code!

    1. Impressive! And nicely documented too.

      > (there seem to be very few Jelly examples out there).

      I think that's because it's not strongly supported by Atlassian (or used anywhere else since maven dropped it in v2). I use it occasionally if I have a client who wants to change their JIRA but doesn't have access to a command line prompt. Otherwise I tend to use the SOAP API and a scripting language such as Python.

      But pragmatics trumps approach here.

      ~Matt

  15. Anonymous

    Can you create users who are authenticated externally ( LDAP /ActiveDirectory )  via a Jelly script? The equivalent of not providing a password and leaving the Send Password Email box unchecked ( Uncheck this option if you are using a LDAP server )

    1. Yes, this is exactly what the Importing user from LDAP article discusses.