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.
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}
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?
@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
@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)
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!
@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?
@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)
@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.
@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
100 comments