From 30aed3da5a7966cbd653644d5f53a2e1990a9e70 Mon Sep 17 00:00:00 2001 From: kemuri Date: Fri, 3 Feb 2023 17:08:47 +0100 Subject: [PATCH] favor credentials from environment --- README.md | 2 ++ generate-changelog.py | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index af5e72c..8b9bd8b 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ None of them is dealing with jira. - setup jira url - define jira projects in which fix version should be created - configure possible issue type for your project +- export JIRA_SERVER url, JIRA_USER and JIRA_PASSWORD to environment + ### getting version info currently the script parses a gradle property file, tweak the script to your needs: e.g. pass info via argument, PR diff --git a/generate-changelog.py b/generate-changelog.py index 0de1da8..469263a 100755 --- a/generate-changelog.py +++ b/generate-changelog.py @@ -7,6 +7,7 @@ # install via `pip install jira` # https://jira.readthedocs.io/en/master/api.html#issue +import os import sys import subprocess import re @@ -15,15 +16,6 @@ # ~^~^~^~ user config ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~ -# point to your jira installation -jira_server = 'https://jira.yourdomain.com' - -""" -configure authentication, see jira module docs for more auth modes -https://jira.readthedocs.io/en/latest/examples.html#authentication -""" -jira = JIRA(server=(jira_server), basic_auth=('changelogbot', 'cryp71cp455w0rd')) - changelogFilename = "CHANGELOG.md" # configure possible issue types @@ -44,6 +36,16 @@ # ^-^-^ END user config ^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^ +""" +Credentials for authentication should be provided by environment. +Feel free to come up with a more secure option. +See jira module docs for more auth modes +https://jira.readthedocs.io/en/latest/examples.html#authentication +""" +jira_server = os.environ['JIRA_SERVER'] +jira_username = os.environ['JIRA_USER'] +jira_password = os.environ['JIRA_PASSWORD'] +jira = JIRA(server=(jira_server),basic_auth=(jira_username, jira_password)) project_format = r'[A-Z][A-Z\d]+' git_cmd = 'git log $(git describe --abbrev=0 --tag)..HEAD --format="%s"'