|
|
|
| Line 1: | |||
| This page lists recipient generator scripts to be used in conjunction with notification schemes. These scripts were taken straight from the [https://bugs.urbancode.com/secure/IssueNavigator.jspa?reset=true&&pid=10110&sorter/field=issuekey&sorter/order=ASC public JIRA site]. Please note that some scripts may be ''snippets'' and '''probably WILL need''' modification to work properly for your situation. Treat these as templates that you can modify from. | This page lists recipient generator scripts to be used in conjunction with notification schemes. These scripts were taken straight from the [https://bugs.urbancode.com/secure/IssueNavigator.jspa?reset=true&&pid=10110&sorter/field=issuekey&sorter/order=ASC public JIRA site]. Please note that some scripts may be ''snippets'' and '''probably WILL need''' modification to work properly for your situation. Treat these as templates that you can modify from. | ||
| + | = Uses Committers But Need to Modify Repository Username = | ||
| + | You could have repository users that are close to Anthill user names and their is a easy operation to map the two and it is painful to add repository aliases for every user. | ||
| + | Script Notes: | ||
| + | * This script strips off everything before the first '\' | ||
| + | ==== AHPSCRIPTS-68 ==== | ||
| + | <pre>import com.urbancode.anthill3.domain.security.*; | ||
| + | org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("Committer Notification"); | ||
| + | userSet = new java.util.HashSet(); | ||
| + | changelogs = ChangeLogHelper.getChangeLogArray(workflow); | ||
| + | repoId = workflow.getBuildLife().getProfile().getSourceConfig().getRepository().getId(); | ||
| + | for (int i = 0; i < changelogs.length; i++){ | ||
| + | changesets = changelogs[i].getChangeSetArray(); | ||
| + | for (int j = 0; j < changesets.length; j++){ | ||
| + | username = changesets[j].getUser(); | ||
| + | // remove the domain name from the repo user name | ||
| + | username = username.substring(username.indexOf("\\") + 1); | ||
| + | tempUsers = UserFactory.getInstance().restoreAllForChangelogNameAndRepository(username, repoId); | ||
| + | if (tempUsers.length == 0) { | ||
| + | log.warn("Did not find a user matching developer name '" + username + "'"); | ||
| + | } | ||
| + | |||
| + | com.urbancode.commons.util.CollectionUtil.addAll(userSet, tempUsers); | ||
| + | } | ||
| + | } | ||
| + | result = new User[userSet.size()]; | ||
| + | userSet.toArray(result); | ||
| + | activeUsers = new java.util.ArrayList(); | ||
| + | for ( int i = 0; i < result.length; i++ ) { | ||
| + | if ( !result[i].isDeleted() && !result[i].isInactive()) { | ||
| + | activeUsers.add(result[i]); | ||
| + | } | ||
| + | } | ||
| + | return (User[]) activeUsers.toArray(new User[activeUsers.size()]);</pre> | ||