It's all about the answers!

Ask a question

Who run event handler?


Michele Pegoraro (1.8k14118103) | asked Aug 27 '09, 9:42 a.m.
Hi, I've some rights problem running an event handler on Build Result Changed. I want to change state to a work-item linked to BuildResult. I'm able to retrieve the work-item and the action to perform, but when I try to run the change of state I've got an exception of Authorization denied on running that specific action. But the user that requires the build has the permission to change that state and also the user running the build.
I've also tried to put all grants on everyone and only then I can change-state.
Both my user are in Project Area and Team Area.

Any idea??

9 answers



permanent link
Michele Pegoraro (1.8k14118103) | answered May 26 '11, 10:00 a.m.
Thank you very much.

This explain why I have never been able to set it. Now I'll take a look to the service you've suggested.

Best regards,
Michele.

permanent link
Nick Edgar (6.5k711) | answered May 26 '11, 9:49 a.m.
JAZZ DEVELOPER
Hi Michele,

The runAsUser setting is ignored (and has been since 1.0). Having the setting still there is admittedly confusing. I've filed 167352: ProcessChangeEventTask ignores runAsUser setting and cc'ed you.

If your event handler needs to run as a different user (perhaps the user can be recovered from the event), you can use com.ibm.team.repository.service.IImpersonationService to run code under a different user.

permanent link
Michele Pegoraro (1.8k14118103) | answered May 26 '11, 7:01 a.m.
Hi, I'm facing the same problem.

I use event management in order to perform some action like saving wi attributes or delivering change-set. But I want to give permission on these operation only to a technical user, not to everyone. But even if I set my user on com.ibm.team.process.internal.service.ProcessChangeEventsTask instead of ADMIN, when my event extension runs, it has ADMIN as event author.

Any suggestion on how to change this user?

permanent link
Nick Edgar (6.5k711) | answered Sep 10 '09, 9:14 a.m.
JAZZ DEVELOPER
I think this kind of workflow transition would be better done as an explicit Ant task (contributed to the build toolkit), or as a post-build participant (see http://jazz.net/forums/viewtopic.php?p=22695).

Note that the initiating contributor will be ADMIN for a scheduled build.
To determine whether a build is a scheduled one (vs. manually requested), use IBuildResultRecord.isScheduledBuild(), where records are obtained from IBuildResultRecordClient on the client side. Its implementation, if you don't want to deal with records, is:

public boolean isScheduledBuild() {
for (IBuildRequest buildRequest : getBuildRequests()) {
if (buildRequest.getBuildAction().getAction().equals(IBuildAction.REQUEST_BUILD)) {
IBuildProperty property = buildRequest.getBuildDefinitionInstance().getProperty(
IBuildScheduleTaskProperties.PROPERTY_SCHEDULED_BUILD);
if (property != null) {
String value = property.getValue();
return Boolean.parseBoolean(value);
}
}
}
return false;
}


To get the request items, use IBuildResult.getBuildRequests() then fetch the items. Be sure to use a profile to fetch only the properties you need, as these items can be quite large (e.g. they include a copy of the build definition including all its properties).

permanent link
Michele Pegoraro (1.8k14118103) | answered Sep 10 '09, 3:44 a.m.
My intent is to perform a change-state after a successful build.
In this handler i wrote, I control the build status and if it is completed and successful I perform a query on the work item in a specific workflow state and than for all these I run a specific workflow action.

I'd like to exclude a specific role (I've call it "Administrators") for this handler so I was watching on how to do with built-in configuration. Thanks to Jared, I've found that the event handler is managed from ADMIN user (and I don't want to change it), so I have had to configure this handler on Everyone role instead of all the roles with the exception of "Administrator", and than I have used coding in the plugin to catch the requestor of the build using IBuildRequest.getInitiatingContributor() and than retrieving the role.

I don't know if there is another (better) way to do it.

permanent link
Nick Edgar (6.5k711) | answered Sep 09 '09, 3:38 p.m.
JAZZ DEVELOPER
Can you tell us more about your scenario? It seems strange to be making modifications to work items as a side effect of build events. Maybe this should be done as a build participant, or an Ant task as an explicit step in the build script.

permanent link
Michele Pegoraro (1.8k14118103) | answered Aug 28 '09, 3:38 a.m.

On the Advanced Properties page in the admin web ui, you can configure
the user ID which will be used to execute all process change event
handlers.

In the admin web ui, click the Server link on the top 'toolbar', then
select Advanced Properties on the left. Finally, search for
"ProcessChangeEventsTask" to jump to the property.

Thank you for the answer. So has a user be defined, which has to be included, with specific role permission, on all the project area and team area? Or maybe is it better to use, as I said in previous reply, the Everyone role?

permanent link
Michele Pegoraro (1.8k14118103) | answered Aug 27 '09, 10:18 a.m.
I've find out that the only way to perform the state change is that the operation of change-state permormed inside the event handler must be permitted by "Everyone" role. I can't define the permission to a specific role.
It seems a little bit wrong this behaviour, IMHO.

permanent link
Jared Burns (4.5k29) | answered Aug 27 '09, 9:47 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
On Thu, 27 Aug 2009 13:53:02 +0000, mikyjpeg wrote:

Hi, I've some rights problem running an event handler on Build Result
Changed. I want to change state to a work-item linked to BuildResult.
I'm able to retrieve the work-item and the action to perform, but when I
try to run the change of state I've got an exception of Authorization
denied on running that specific action. But the user that requires the
build has the permission to change that state and also the user running
the build.
I've also tried to put all grants on everyone and only then I can
change-state.
Both my user are in Project Area and Team Area.

Any idea??

On the Advanced Properties page in the admin web ui, you can configure
the user ID which will be used to execute all process change event
handlers.

In the admin web ui, click the Server link on the top 'toolbar', then
select Advanced Properties on the left. Finally, search for
"ProcessChangeEventsTask" to jump to the property.


--
Jared Burns
Jazz Process Team

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.