Skip to content
Snippets Groups Projects
Commit bc02d62e authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Adding more details to the conflict log file

parent 50219adb
No related branches found
No related tags found
No related merge requests found
...@@ -55,9 +55,9 @@ echo "\n------ Getting all potential conflicting merge requests --------" ...@@ -55,9 +55,9 @@ echo "\n------ Getting all potential conflicting merge requests --------"
# Initialize an empty array to store conflicting merge requests # Initialize an empty array to store conflicting merge requests
conflicting_merge_request_ids=() conflicting_merge_request_ids=()
if [ ${3} == "all" ] ; then if [ ${3} == "all" ] ; then
merge_requests=$(curl "${1}/projects/${2}/merge_requests?state=opened&target_branch=${4}") merge_requests=$(curl --header "PRIVATE-TOKEN: ${10}" "${1}/projects/${2}/merge_requests?state=opened&target_branch=${4}")
else else
merge_requests=$(curl "${1}/projects/${2}/merge_requests?state=opened&milestone=${3}&target_branch=${4}") merge_requests=$(curl --header "PRIVATE-TOKEN: ${10}" "${1}/projects/${2}/merge_requests?state=opened&milestone=${3}&target_branch=${4}")
fi fi
echo "${merge_requests}" | jq -c '.[]' | while read mr; do echo "${merge_requests}" | jq -c '.[]' | while read mr; do
mr_id=$(echo "$mr" | jq '.iid') mr_id=$(echo "$mr" | jq '.iid')
...@@ -86,6 +86,14 @@ echo "${merge_requests}" | jq -c '.[]' | while read mr; do ...@@ -86,6 +86,14 @@ echo "${merge_requests}" | jq -c '.[]' | while read mr; do
result=$? result=$?
if [ ! $result == 0 ] ; then if [ ! $result == 0 ] ; then
echo "Merge request title: ${mr_title}, Merge Request ID: ${mr_id}" >> conflicting_merge_requests.txt echo "Merge request title: ${mr_title}, Merge Request ID: ${mr_id}" >> conflicting_merge_requests.txt
spec=$(git diff --name-only --diff-filter=U | grep -E "(TS|TR)")
sed -n '
/^<<<<<<< /,/^>>>>>>> / {
/^<<<<<<<\|^>>>>>>>/!{=;p}
/^>>>>>>> /a\
}
' ${spec} >> conflicting_merge_requests.txt
conflicting_merge_request_ids+=("${mr_id}") conflicting_merge_request_ids+=("${mr_id}")
# Setting label to the merge request which is conflicting with # Setting label to the merge request which is conflicting with
echo "Setting label to the merge request which is conflicting with: ${mr_id}" echo "Setting label to the merge request which is conflicting with: ${mr_id}"
......
...@@ -40,12 +40,12 @@ Checking conflicts: ...@@ -40,12 +40,12 @@ Checking conflicts:
# Installation of required software # Installation of required software
- apt-get update -qq && apt-get -qq install -y git curl jq > /dev/null - apt-get update -qq && apt-get -qq install -y git curl jq > /dev/null
- | - |
curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/checking_conflicts%2Esh/raw?ref=master" >> checking_conflicts.sh curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/checking_conflicts%2Esh/raw?ref=detailsConflicts" >> checking_conflicts.sh
- chmod +x checking_conflicts.sh - chmod +x checking_conflicts.sh
- git clone "https://$CI_SERVER_HOST/$CI_PROJECT_PATH.git" ${CI_PROJECT_NAME} - git clone "https://oauth2:${PIPELINE_ACCESS_TOKEN}@$CI_SERVER_HOST/$CI_PROJECT_PATH.git" ${CI_PROJECT_NAME}
script: script:
- echo 'Checking conflicts' - echo 'Checking conflicts'
- ./checking_conflicts.sh ${CI_API_V4_URL} ${CI_MERGE_REQUEST_PROJECT_ID} ${MERGE_REQUEST_MILESTONE} ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} ${CI_MERGE_REQUEST_IID} ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} ${CI_PROJECT_NAME} "$GITLAB_USER_NAME" $GITLAB_USER_EMAIL $MIKE_ACCESS_TOKEN - ./checking_conflicts.sh ${CI_API_V4_URL} ${CI_MERGE_REQUEST_PROJECT_ID} ${MERGE_REQUEST_MILESTONE} ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} ${CI_MERGE_REQUEST_IID} ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} ${CI_PROJECT_NAME} "$GITLAB_USER_NAME" $GITLAB_USER_EMAIL $PIPELINE_ACCESS_TOKEN
artifacts: artifacts:
when: on_failure when: on_failure
paths: paths:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment