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 vote
Accepted answer

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
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,711 views 17 21
Read article

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