Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Mention someone directly in Slack via Jira Automation

80 comments

Darla Sheehan July 17, 2023

Ugh @Jeremy Jones ... Sorry, I only had to do a few manually. Maybe Atlassian support can offer to bulk change them if that is the case. Worth raising a ticket to find out, especialy if you are on Jira Cloud.

Like Jeremy Jones likes this
권동호 September 25, 2023

 

python3 sync.py --slack_token $SLACK_TOKEN --jira_url $JIRA_URL --username $USERNAME --apikey $APIKEY

If you run the above command in cmd, you will get an error as shown in the image below.
Please let me know how to solve it.

image.png

armcaelria September 25, 2023

@권동호  you need to replace $SLACK_TOKEN, $JIRA_URL, $USERNAME and $APIKEY with actual data. How to get this data described in the article

권동호 September 25, 2023

@armcaelria I'd appreciate it if you could tell me which parts of the image below I need to change.image.png

armcaelria September 25, 2023

@권동호  it seems like something normal. Can you provide the full command that you try to execute? (with censor, of course)

권동호 September 25, 2023
python3 sync.py --slack_token $SLACK_TOKEN --jira_url $JIRA_URL --username $USERNAME --apikey $APIKEY

 @armcaelria 

I tried to run the above command to make the script work.

After navigating to the file location using the cmd console, I ran the command.

I followed the same steps as the tutorial, but I'm stuck on running the script.

armcaelria September 25, 2023

@권동호 Are you trying to run the command 

python3 sync.py --slack_token $SLACK_TOKEN --jira_url $JIRA_URL --username $USERNAME --apikey $APIKEY

without actual data from your environment? 

This command need to replace $SLACK_TOKEN, $JIRA_URL, $USERNAME and $APIKEY with your actual data

Something like this 

python3 sync.py --slack_token {put your slack token here} --jira_url {put your jira url here}--username {put your username here} --apikey {put your api here}
Like 권동호 likes this
권동호 September 25, 2023

@armcaelria It worked, thank you so much. Have a great day!

Brad Miele September 27, 2023

Just installed and I am getting a "no user found for <email address>" error on every user. any tips?

armcaelria September 27, 2023

@Brad Miele sound like you don't have access to jira users or no users in jira using the same email for slack

Brad Miele September 27, 2023

@armcaelria thanks for the response!

apologies, my python is not the best, I had chatgpt write the below code to check my access. etc, and when I run it, it works just fine. 

 

import requests
from requests.auth import HTTPBasicAuth
import json

# Input your Jira domain, email, and API token
jira_domain = xxxxxxxxxxxxxx
email = 'brad.miele@simulation.science'
api_token = xxxxxxxxxxxxx

# Input the email address to search for
search_email = input("Enter the email address to search for: ")

# Construct the URL for the Jira REST API user search endpoint
url = f"{jira_domain}/rest/api/3/user/search?query={search_email}"

# Make the GET request to the Jira REST API
response = requests.get(url, auth=HTTPBasicAuth(email, api_token))

# Check the HTTP response status code
if response.status_code == 200:
# Parse the JSON response
users = response.json()

# Check if any users were found
if users:
print(f"Users found for {search_email}:")
for user in users:
print(user.get('accountId'))
else:
print(f"No users found for {search_email}.")
else:
print(f"Failed to search users. HTTP Response Code: {response.status_code}")
print(response.text)

 I was going to try swapping out the existing lookup with this code, but as I said, my python isn't the best, is there something simple that explains the difference in results?

armcaelria September 27, 2023

@Brad Miele 1st - why don`t you want just to follow the article`s script? 2nd - try to print request response in 200 status to provide more information

armcaelria September 27, 2023

@Brad Miele and try to use this format in your script https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-user-search/#api-rest-api-3-user-search-get (in short - provide query in request params, not in get params) 

Brad Miele September 27, 2023

@armcaelria I needed to call the script with my full username + @email.address for it to work, thanks for the help. 

Like Karishma Walia likes this
Ian Sheffield October 20, 2023

@Daniel Eads - just a note for anybody who gets stuck using the latest stable python version 3.12 that the slack library doesn't appear to be compatible with it.

pip3 install slackclient will fail attempting to build the aiohttp wheel 

After searching through stackexchange it was noted that the package is not yet compatible with 3.12, and downgrading to python 3.11 will resolve.  (which it did)

Like Dave Beaudoin likes this
Matas Gasparavičius October 25, 2023

Does anyone know if it's possible to send Direct messages not only through Slackbot? 

Naoya Nakamura
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 13, 2023

Hi!

When I executed it, a warning appeared, so I would like to know how to deal with it.

 

/Users/naoyanakamura/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
warnings.warn(
WARNING:root:No user found for the given Slack workspace associated with token. Exiting!
Naoya Nakamura
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 13, 2023

If you are in Slack using Slack Connect, can you link it to JIRA?

Mario Coluzzi January 29, 2024

It seems that this solution is for Data Centre only. What about Cloud?

armcaelria January 29, 2024

@Mario Coluzzi This is working for Jira Cloud as well

armcaelria January 29, 2024

@Naoya Nakamura If it still actual. You are using token for slack user, that is not in workspace you try to connect

Mario Coluzzi January 30, 2024

@armcaelriaif this solution is functioning correctly for Cloud, may I inquire about the location where the Python script should be installed in order for it to operate? From the response, it appears that this solution is deployed on a standalone laptop. This option seems somewhat cumbersome and not quite suitable for implementation within an enterprise structure. What are your thoughts on this matter?

armcaelria January 30, 2024

@Mario Coluzzi you can run this script at any machine that has connection to internet and able to execute python scripts. If you need to run this script at frequent basis (i.e. if you constantly growing and have new people) you can hang this for some repeatable job like cron. It's don't influence any previously added users but add new users as well. If you don't want to run script at all than you can manually add the property to each user via API but this is not the best solution due to complexity (if you don't use some bash script or something similar)

Mario Coluzzi January 30, 2024

@armcaelria it is not a professional viable solution. The machine can be compromised or can perform a not authorized job and furthermore this "amatorial solution" should be removed from Atlassian due to potential harm it can do to a Live Environment.

armcaelria January 30, 2024

@Mario Coluzzi  The only way to use this solution but not run the script at all is add property to each new user manually via API. It is possible but not so easy. In this case you don't need to use any automatic scripts what can cause some harm for your environment. 

About your opinion about removing this solution - it's mean to remove any API usage for Jira Cloud what doesn't seems possible

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events