feat(commit.py): throw an error if no token was supplied. i.e. empty variable.

A check is done on the supplied token,
if 'None', throws an error that can be viewed in the output log and
in the job output.

fixes #11 !12
This commit is contained in:
2022-01-15 13:08:52 +09:30
parent 6b7ad95fc0
commit e5531fc77b
2 changed files with 3 additions and 4 deletions

View File

@ -55,10 +55,7 @@ MR Title:
extends: extends:
- .conventional_commit - .conventional_commit
script: script:
- echo "[DEBUG] Merge Request Title[$($ROOT_DIR/conventional_commits/scripts/commit.py --token "$MR_ACCESS_TOKEN" --project $PROJECT_ID --title --branch $CI_COMMIT_BRANCH)]"
- $ROOT_DIR/conventional_commits/scripts/commit.py --token "$MR_ACCESS_TOKEN" --project $PROJECT_ID --title --branch $CI_COMMIT_BRANCH
- cz_exit=0 && cz check --message "$($ROOT_DIR/conventional_commits/scripts/commit.py --token "$MR_ACCESS_TOKEN" --project $PROJECT_ID --title --branch $CI_COMMIT_BRANCH)" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$? - cz_exit=0 && cz check --message "$($ROOT_DIR/conventional_commits/scripts/commit.py --token "$MR_ACCESS_TOKEN" --project $PROJECT_ID --title --branch $CI_COMMIT_BRANCH)" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$?
- . $ROOT_DIR/conventional_commits/scripts/cz_junit.sh > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME-cz.junit.xml" - . $ROOT_DIR/conventional_commits/scripts/cz_junit.sh > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME-cz.junit.xml"

View File

@ -26,6 +26,8 @@ for opt, arg in opts:
print('[commit.py] -i <inputfile> -o <outputfile>') print('[commit.py] -i <inputfile> -o <outputfile>')
sys.exit() sys.exit()
elif opt in ("-t", "--token"): elif opt in ("-t", "--token"):
if arg is None:
raise ValueError('Token switch was specified, however no token was supplied.')
ci_job_token = arg ci_job_token = arg
elif opt in ("-ti", "--title"): elif opt in ("-ti", "--title"):
get_mr_title = True get_mr_title = True