Skip to content
Snippets Groups Projects
Commit 35a541de authored by Alan Nelson's avatar Alan Nelson
Browse files

Integrate new bash script into approval check flow

parent 14abc16b
No related branches found
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,9 @@
#CI_COMMIT_BEFORE_SHA=""
#CI_COMMIT_SHA=""
# 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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment