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

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

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 Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

206 views 1 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