|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# © Copyright IBM Corporation 2019, 2020 |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +GREEN="\033[32m" |
| 18 | +RED="\033[31m" |
| 19 | + |
| 20 | +END="\033[0m" |
| 21 | + |
| 22 | +RIGHTARROW="\xE2\x96\xB6" |
| 23 | +GREENRIGHTARROW=${GREEN}${RIGHTARROW}${END} |
| 24 | + |
| 25 | +TICK="\xE2\x9C\x94" |
| 26 | +CROSS="\xE2\x9C\x97" |
| 27 | +GREENTICK=${GREEN}${TICK}${END} |
| 28 | +REDCROSS=${RED}${CROSS}${END} |
| 29 | + |
| 30 | +printf "${GREENRIGHTARROW} Attempting to trigger new release-checks build\n" |
| 31 | + |
| 32 | +repo_name=$(echo "${TRAVIS_REPO_SLUG}" | cut -d'/' -f2-) |
| 33 | + |
| 34 | +request_body="{ \"request\": { \"message\": \"Trigger release checks build from ${repo_name}:${TRAVIS_BRANCH}\", \"branch\": \"main\", \"merge_mode\": \"deep_merge_append\", \"config\": { \"env\": { \"global\": [ \"EVENT_SOURCE=${repo_name}\" ]}}}}" |
| 35 | + |
| 36 | +request_response="$(curl -X POST -H "Content-Type: application/json" -H "Travis-API-Version: 3" -H "Authorization: token ${TRAVIS_TOKEN}" -d "${request_body}" https://v3.travis.ibm.com/api/repo/mq-cloudpak%2Frelease-checks/requests -o /dev/null -w "%{http_code}" -s)" |
| 37 | +if [ "$request_response" != "202" ]; then |
| 38 | + printf "${REDCROSS} ${RED}Could not create new request${END}\n" |
| 39 | + exit 1 |
| 40 | +else |
| 41 | + printf "${GREENTICK} Successfully created new request\n" |
| 42 | +fi |
0 commit comments