From b648aa2cd8212e9264e06df35acd1b5c24c1e7d7 Mon Sep 17 00:00:00 2001 From: Patryk Gudalewicz Date: Thu, 28 Jul 2022 09:10:34 +0200 Subject: [PATCH] Implemented basic auth (personal access token) --- createDash.py | 6 ++++-- readme.md | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/createDash.py b/createDash.py index 9138136..9e1571c 100644 --- a/createDash.py +++ b/createDash.py @@ -8,15 +8,17 @@ from git import Repo import os #set STAGING global dashboard name DASHBOARD_NAME = "[STAGING]Global Offboard Reliability - Touchpoint Mobile #" -CONFIG_REPO_URL = "https://atc.bmwgroup.net/bitbucket/scm/opapm/shared_configuration.git" +AUTHSTRING = config("BITBUCKET_USERNAME")+":"+config("BITBUCKET_TOKEN") +CONFIG_REPO_URL = "https://"+AUTHSTRING+"atc.bmwgroup.net/bitbucket/scm/opapm/shared_configuration.git" CONFIG_REPO_NAME = "shared_configuration" -ARCHIVE_REPO_URL = "https://atc.bmwgroup.net/bitbucket/scm/opapm/archive.git" +ARCHIVE_REPO_URL = "https://"+AUTHSTRING+"atc.bmwgroup.net/bitbucket/scm/opapm/archive.git" ARCHIVE_REPO_NAME = "archive" parser = argparse.ArgumentParser(description="Generate and deploy the Dynatrace Global Dashboard as Code. Auto deployment works only for STAGING dashboard", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("-R", "--rows", type=int, help="Number of rows per dashboard. If not specified, all rows will be added to single dashboard") parser.add_argument('--auto-upload', default=False, action='store_true', help="Auto upload to STAGING dashboard") + args = parser.parse_args() def clone_repo_if_notexist(repourl, reponame): if(not os.path.isdir(reponame)): diff --git a/readme.md b/readme.md index f9fdd2c..240568c 100644 --- a/readme.md +++ b/readme.md @@ -32,7 +32,11 @@ Before executing scripts, python requirements have to be satisfied. To do so, ex To provide authentication for API calls, create ".env" file in the script directory with following definition: = - is name of environment variable. This name should be passed to "environment.yaml" file as "env-token-name" parameter + is name of environment variable. This name should be passed to "environment.yaml" file as "env-token-name" parameter + BITBUCKET_USERNAME= + for bitbucket account with read access to shared_configuration repo and R/W access to archive repo + BITBUCKET_TOKEN= + personal access token for BITBUCKET_USERNAME with repo write permissions. For more information see https://confluence.atlassian.com/bitbucketserver0717/personal-access-tokens-1087535496.html?utm_campaign=in-app-help&utm_medium=in-app-help&utm_source=stash#Personalaccesstokens-usingpersonalaccesstokens # Usage