So I've been using Adaptvists Scriptrunner for cloud and have added in a script listener that is supposed to be listening for the `user_created` event.
It seems this is working for the users created for our Service Desk but it doesn't seem to trigger for users created by the Google Suite integration.
Basically what I want to do is automatically create a task in a project to notify me that I need to go and figure out what groups the user needs to be added to.
Has anyone else had any issues with this `user_created` event?
Never mind - turns out I'm just not patient enough...
For the curious, I'll attach my script for Google search completeness. (Feel free to use as necessary)
// Pre check - because `accountType` can't be checked in the condition
def userDetails = get("/rest/api/3/user?accountId=${user.accountId}").asObject(Map).body
logger.info("Account Type is ${userDetails.accountType}")
if (userDetails.accountType != "atlassian") return
// Definitions
def projectKey = 'KEY'
def issueTypeName = 'Atlassian Request'
def componentName = 'Atlassian'
def adminUrl = "https://admin.atlassian.com/s/<redacted>/users/${user.accountId}"
// In my case this should be fine even with GDPR as by default all this is "on"
// when being generated from Google Suite integration
def username = userDetails.displayName ?: userDetails.name ?: userDetails.emailAddress
// Related Values Search
def issueTypeId = get('/rest/api/3/issuetype').asObject(List).body.find { it['name'] == issueTypeName }['id']
def atlassianComponentId = get("/rest/api/3/project/${projectKey}/component")
.header('Content-Type', 'application/json')
.asObject(Map).body.values.find { it['name'] == componentName }['id']
// Build Description
def adminLink = [
type: "text",
text: "Admin Page For ${username}",
marks: [
[
type: "link",
attrs: [
href: adminUrl
] as Map
] as Map
] as List
] as Map
def description = [
version: 1,
type: "doc",
content: [
[
type: "paragraph",
content: [
[
type: "text",
text: "A new user has been added, please setup their correct access. "
] as Map
] as List
] as Map,
[
type: "paragraph",
content: [
adminLink
] as List
] as Map
] as List
] as Map
post('/rest/api/3/issue')
.header('Content-Type', 'application/json')
.queryString("overrideScreenSecurity", true)
.body(
[
fields: [
summary : "New User Added: ${username}",
description: description,
project : [
key: projectKey
],
issuetype : [
id: issueTypeId
],
components: [
[ id: atlassianComponentId ]
]
]
])
.asObject(Map).body
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.