script to change passwords for existing users

r
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.
November 21, 2012

Hello,

is there a possibility to change the passwords for users using jelly script? If yes, could you provide me with an example?

Thanks,

Rad

3 answers

1 accepted

1 vote
Answer accepted
Renjith Pillai
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.
December 25, 2012

Based on John's input, I changed slightly to use the new class (as opensymphony is not supported anymore).

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib"
xmlns:core="jelly:core" xmlns:log="jelly:log" xmlns:util="jelly:util" >
<jira:Login username="admin" password="sphere">
 
  <core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getUserManager" var="userManager"/>
  <core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getUserUtil" var="userUtil"/>

  <core:invoke on="${userManager}" method="getUserByName" var="user">
    <core:arg type="java.lang.String" value="fred"/>
  </core:invoke>
  <core:invoke on="${userUtil}" method="changePassword">
      <core:arg type="com.atlassian.crowd.embedded.api.User" value="${user}"/>
      <core:arg type="java.lang.String" value="secret"/>
  </core:invoke>
</jira:Login>
</JiraJelly>

1 vote
John Chin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 18, 2012

Hi there,

Here are the short jelly script and I haven't tested on it. Hope it help and good luck.

<JiraJelly xmlns:jira="jelly:com.atlassian.jira.jelly.enterprise.JiraTagLib"
xmlns:core="jelly:core" xmlns:log="jelly:log" xmlns:util="jelly:util" >
<jira:Login username="admin" password="password">

 
  <!-- Grab an instance of UserManager -->
  <core:invokeStatic className="com.opensymphony.user.UserManager" method="getInstance" var="userManager"/>

  <!-- Get the User from UserManager -->

<core:invoke on="${userManager}" method="getUser" var="user">
    <core:arg type="java.lang.String" value="username"/>
  </core:invoke>

  <core:invoke on="${user}" method="setPassword">
      <core:arg type="java.lang.String" value="secret"/>
  </core:invoke>

</jira:Login>
</JiraJelly>

0 votes
Gabriel Galibourg October 21, 2013
Based on Renjith's and John's answers above, improved further for Jira 6

<JiraJelly
  xmlns:jira="jelly:com.atlassian.jira.jelly.JiraTagLib"
  xmlns:core="jelly:core" xmlns:log="jelly:log" xmlns:util="jelly:util" >

<jira:Login username="admin" password="sphere">
 
  <core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getUserManager" var="userManager"/>
  <core:invokeStatic className="com.atlassian.jira.component.ComponentAccessor" method="getUserUtil" var="userUtil"/>
  <core:invoke on="${userManager}" method="getUserByName" var="user">
    <core:arg type="java.lang.String" value="fred"/>
  </core:invoke>
  <core:invoke on="${user}" method="getDirectoryUser" var="directoryUser" />
  <core:invoke on="${userUtil}" method="changePassword">
      <core:arg type="com.atlassian.crowd.embedded.api.User" value="${directoryUser}"/>
      <core:arg type="java.lang.String" value="secret"/>
  </core:invoke>
</jira:Login>
</JiraJelly>

Royce Wong
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 18, 2015

How do you update e-mail address???

Suggest an answer

Log in or Sign up to answer