Skip to content
Snippets Groups Projects
Commit 73c51ffd authored by Nick Barry's avatar Nick Barry
Browse files

Merge branch 'integrate-sh-script' into 'merge-request-check-enhancements'

Integrate bash script

See merge request !93
parents 14abc16b cc53a1e9
Branches
No related tags found
3 merge requests!94Merge Request Check Updates,!93Integrate bash script,!91New Merge Request Helper
......@@ -14,9 +14,12 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
RUN mkdir /code
WORKDIR /code
RUN apk add --no-cache bash git
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY approval_check.py ./
COPY merge_review_check.sh ./
CMD ["python", "approval_check.py"]
import os
import requests
import subprocess
import sys
'''
......@@ -18,11 +19,23 @@ response = requests.post('https://its-lampprod1-whm.unl.edu/merge_auth_check.php
'user': os.environ.get('GITLAB_USER_LOGIN')
})
if (response.status_code == 200):
if response.status_code == 200:
# Merge is allowed, print response and exit cleanly (status 0)
print(response.content.decode('utf-8'))
exit(0)
elif response.status_code == 403:
# Merge is not allowed, run further checks to see if a review is needed.
result = subprocess.run(['bash', '/code/merge_review_check.sh'], capture_output=True, text=True)
# Print output from additional checks script
print(result.stdout)
print(result.stderr, file=sys.stderr)
# Exit using the exit code form the check script
exit(result.returncode)
else:
# Merge is not allowed, print response and exit with an error (status 1)
# API call failed. Server may be down, or other setup failure. Exit with an error (status 1)
print('Merge request approval check API call failed')
print(f'API Call Status Code: {response.status_code}')
print(response.content.decode('utf-8'), file=sys.stderr)
exit(1)
......@@ -6,6 +6,15 @@
#CI_COMMIT_BEFORE_SHA=""
#CI_COMMIT_SHA=""
# For merge request pipelines, the before SHA is all 0s.
# Replace with a MR specific variable for these pipelines.
if [[ $CI_PIPELINE_SOURCE = 'merge_request_event' ]]; then
CI_COMMIT_BEFORE_SHA="$CI_MERGE_REQUEST_DIFF_BASE_SHA"
fi
# If any commands in this scprt fail, exit with a non-zero exit code
set -e
# Function to check for ASP.NET controls and directives
check_aspx() {
local content="$1"
......
requests==2.22.0
\ No newline at end of file
certifi==2024.7.4
chardet==3.0.4
charset-normalizer==3.3.2
idna==2.8
requests==2.32.3
urllib3==2.2.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment