Hi everyone,
Jira Version : 7.9.2
ScriptRunner : 5.4.12
I have a post-function custom groovy script which i try to start synchronization of crowd directory. But when transition is over (post-function seems to be working), synchronization of directory didn't starts. Here's the weird part. If i run the same code at the script-runner console ; synchronization starts and finished. (I check the jira user directory page to see sync is started or not.)
import com.atlassian.crowd.embedded.api.CrowdDirectoryService
import com.atlassian.crowd.embedded.api.Directory
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
def className = "tr.com.foo.Scripts.sync_crowd"
def Logger log = Logger.getLogger(className)
log.debug("Script " + className + " started")
try{
CrowdDirectoryService crowdDirectoryService = ComponentAccessor.getComponent(CrowdDirectoryService.class);
if (crowdDirectoryService != null){
List<Directory> directories = crowdDirectoryService.findAllDirectories();
for (Directory directory : directories){
if (directory.getType().name().equals("CROWD")){
if (crowdDirectoryService.isDirectorySynchronisable(directory.getId())){
crowdDirectoryService.synchroniseDirectory(directory.getId());
log.debug(directory.getId() + " in sync")
}
}
}
}
else{
log.debug ("Directories not found")
}
} catch (Exception e){
log.debug("exception: " + e)
}
This code doesn't work when it is used as a post-function but works if i run it from the script runner console.
What could be the reason for this ?