Is there anyway to import user avatars via script or other means.
We already have everyone's pictures in active directory, and we are using jira delegated authentication.
I'd be willing to write a script that places a JPG on the server and updates SQL if that's possible.
6.3 has a configurable URL for gravatars. Since that release, I've dropped the rewrite rule method and just point to an app that can look up the picture from the mail md5 digest. This could be written as a jira plugin even.
The other reason not to use rewrite rules anymore, is that 6.3 inlines the avatars if they are local, and also latest greenhopper has "first initial" default avatars, which don't play nice with the rewrites.
Thanks, that you pointed this important enterprise feature out - missed it from JIRA 6.3 release notes. Now with help of Confluence Avatar Service we can achieve consistent avatars in Atlassian stack.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
IMHO there is a better alternative, which is to use url redirection to redirect requests for jira avatar images to whatever servlet etc you have that provides images given a user name.
Example of apache rewrite rules:
RewriteRule /jira/secure/useravatar\?size=small&userId=(.*)\& /picture/viewPhoto/$1?width=16&height=16 [L,R] RewriteRule /jira/secure/useravatar\?.*?userId=(\S+?)\b /picture/viewPhoto/$1?width=48&height=48 [L,R] RewriteRule /jira/secure/useravatar\?.*?ownerId=(\S+?)\b /picture/viewPhoto/$1?width=48&height=48 [L,R] RewriteRule /jira/secure/project/AvatarPicker /res/avatarpicker_replacement.htm
Advantage of this is you do not need to maintain a process to keep the jira avatars up to date. Minor changes were required to some jira templates to ensure the userId was always present in the url.
I use the same thing for confluence, fisheye etc, works well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, yes it is. But could also be done with urlrewrite.xml with vanilla jira.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
is this written within the HTTPD file? You mention apache...
Thanks
Darren
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Brilliant - Thanks :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have successfully tested the following script (it assumes the avatars are on the hard drive in d:\temp\avatars and it also assumes the file names are "username.jpg"...the "export from Active directory" part is solved for me by a simple Powershell script and it takes care of correct naming for the files):
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.avatar.Selection; import java.io.FileInputStream; import java.io.File; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; def avaMan = ComponentAccessor.getAvatarManager() // the Avatar Manager is needed to create avatars from files def uMan = ComponentAccessor.getUserManager() // needed to get ApplicationUser objects def avaSe = ComponentAccessor.getAvatarService() // AvatarService associates avatars with users def setter = uMan.getUserByKey("bigadmin"); // put an administrator ID here def p = ~/.*\.jpg/; def d = new File( 'd:\\temp\\avatars' ); // can be whatever path your avatar files are at d.eachFileMatch(p) { f -> def user = f.name.replaceFirst(~/\.[^\.]+$/, ''); def owner = uMan.getUserByKey(user); if (!avaSe.hasCustomUserAvatar(setter, user)) { // we don't want to overwrite avatars for the users who already have custom avatars def avaIS = new FileInputStream (f); def img = ImageIO.read(f); def width = img.getWidth(); def height = img.getHeight(); def midX = width/2; def midY = height/2; def sz = (width < height)? height : width; def ava = avaMan.create(user+'_real.jpg', 'image/jpeg', owner, avaIS, new Selection(Math.max((int)(midX - sz/2),0),Math.max((int)(midY - sz/2),0), sz, sz)); // not an ideal solution, but better than nothing; automatic cropping is a difficult matter anyway avaSe.setCustomUserAvatar(setter, owner, ava.getId()); } f.delete() // cleanup the avatar set }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use plugin Active Directory Integration, which can do this in very easy way. You need to add configuration to connect with Active Directory or Ldap server, then choose import pictures and that's all that you need to do.
https://marketplace.atlassian.com/plugins/com.intenso.jira.plugins.ad-integration-manager
and plugin's documentation: http://plugins.intenso.pl/display/PLUG/Active%20Directory%20Integration%20with%20JIRA
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Septa,
Can you please share some java/servlet code?
And also, what do you do when the original Photo Servelet does not contain info like ownerId or userId? how do you know what user is it?
Thanks,
Roy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stephen,
You might want to refer to our bug report here:
https://jira.atlassian.com/browse/CONF-22298
There is a SQL script that might help you out on this issue. Hope it helps.
Cheers,
Septa Cahyadiputra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Stephen,
It should be possible via scripting - you have access to the JIRA database and AD avatars - it should only be a metter of creating the appropriate query or script.
I'll leave it to a developer to fill in the details of what you may need to do, though.
-Simon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.