Skip to content
Snippets Groups Projects
Commit 51174d26 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #18357 TIME 0:10 create script

parent b5107ce5
No related branches found
No related tags found
No related merge requests found
......@@ -5,10 +5,11 @@ variables:
stages:
- logs
- new_branch
- test
before_script:
- apt-get update > /dev/null
- apt-get update -yqq > /dev/null
- mkdir -p /usr/share/man/man1
- mkdir -p /usr/share/man/man7
#- apt-get install apt-utils -yqq > /dev/null
......@@ -136,3 +137,18 @@ logs:
- BODY="{\"issue\":{\"notes\":\"$NOTE\",\"private_notes\":false}}"
- echo "$BODY"
- curl -v -H 'Content-Type:application/json' -H "X-Redmine-API-Key:$REDMINE_API_KEY" -d "$BODY" -X PUT https://forge.maarch.org/issues/$ISSUE_ID.json
new_branch:
image: debian:10-slim
stage: new_branch
only:
- branches
before_script:
# Install git and curl command
- apt-get update -yqq > /dev/null
- apt install -y curl
- apt install -y jq
script:
- chmod +x ./ci/create_mr.sh
- ./ci/create_mr.sh
#!/bin/bash
structures=$(echo $CI_COMMIT_REF_NAME | tr "/" "\n")
TRACKER=""
US=""
BRANCH=""
IT=1
for item in $structures
do
if [ $IT = 1 ]; then
TRACKER=$item
fi
if [ $IT = 2 ]; then
US=$item
fi
if [ $IT = 3 ]; then
BRANCH=$item
fi
IT=$((IT+1))
done
if [[ -z $TRACKER ]] || [[ -z $US ]] || [[ -z $BRANCH ]]
then
echo "Bad structure to find US ! => [TRACKER]/[US_ID]/[TARGET_BRANCH]"
else
echo $TRACKER
echo $US
echo $BRANCH
echo "GET https://forge.maarch.org/issues/$US.json"
curl -H "X-Redmine-API-Key: ${REDMINE_API_KEY}" -H 'Content-Type: application/json' -X GET https://forge.maarch.org/issues/$US.json > issue_$US.json
SUBJECT=`cat issue_$US.json | jq -r '.issue.subject'`
BODY="{\"id\":\"$CI_PROJECT_ID\",\"source_branch\":\"$CI_COMMIT_REF_NAME\",\"target_branch\":\"$BRANCH\",\"title\":\"WIP:$CI_COMMIT_REF_NAME\",\"description\":\"$SUBJECT\n=> https://forge.maarch.org/issues/$US\",\"remove_source_branch\":\"true\"}"
echo $BODY
echo "POST https://labs.maarch.org/api/v4/projects/$CI_PROJECT_ID/merge_requests"
curl -v -H "PRIVATE-TOKEN: $TOKEN_GITLAB" -H "Content-Type: application/json" -X POST -d "$BODY" "https://labs.maarch.org/api/v4/projects/$CI_PROJECT_ID/merge_requests"
fi
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment