script to change passwords for existing users

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 votes
Renjith Pillai Community Champion Dec 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 votes

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>

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>

How do you update e-mail address???

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,089 views 13 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot