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

This widget could not be displayed.

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>

This widget could not be displayed.

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>

This widget could not be displayed.
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 Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

251 views 1 3
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