Files
cicd_new_version/.gitlab-ci.yml
정훈 변 73c2ef8641 CI 수정
2024-08-01 16:03:05 +09:00

84 lines
2.4 KiB
YAML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

stages:
- version_update
version_update:
image: harbor.exem-oss.org/test/test-runner:latest
stage: version_update
variables:
file1: "./old/old_version.json"
file2: "./new_version.json"
git_token: $TOKEN
git_user: $USER
git_url: $URL
before_script: |
git config --global user.email "sa_8001@ex-em.com"
git config --global user.name "변정훈"
git clone https://${git_user}:${git_token}@${git_url} ./old
script: |
jq_parse() {
jq -r '.[] | "\(.name):\(.version)"' "$1"
}
declare -A old_version
while IFS=: read -r name version; do
old_version["$name"]=$version
done < <(jq_parse "$file1")
declare -a different_names
declare -a different_versions
while IFS=: read -r name version; do
if [[ "${old_version["$name"]}" != "$version" ]]; then
different_names+=("$name")
different_versions+=("$version")
fi
done < <(jq_parse "$file2")
if [ ${#different_names[@]} -gt 0 ]; then
echo "" && echo ""
echo "아래 항목에 대해서 CI 작업을 시작합니다!" && echo ""
for index in "${!different_names[@]}"; do
name="${different_names[$index]}"
version="${different_versions[$index]}"
echo "$name:$version"
case $name in
exemone_java_agent)
curl -s -o /dev/null -X POST \
--fail \
-F "token=$JAVA_AGENT_TOKEN" \
-F "ref=main" \
-F "variables[TRIGGER_NAME]=exemone_java_agent" \
-F "variables[VER]=$version" \
https://lab.jhcloud.kr/api/v4/projects/53/trigger/pipeline
;;
exemone_kafka_agent)
curl -s -o /dev/null -X POST \
--fail \
-F "token=$KAFKA_AGENT_TOKEN" \
-F "ref=main" \
-F "variables[TRIGGER_NAME]=exemone_kafka_agent" \
-F "variables[VER]=$version" \
https://lab.jhcloud.kr/api/v4/projects/54/trigger/pipeline
;;
*)
echo "프로젝트 \"$name\"을(를) 찾을 수 없습니다!" && echo ""
;;
esac
done
echo "" && echo ""
cp $file2 $file1 && cd ./old
git add ./
git commit -m "버전 관리"
git push origin main
else
echo "" && echo "버전이 변한 애플리케이션이 없습니다." && echo ""
fi
except:
variables:
- $CI_COMMIT_MESSAGE =~ /CI 수정/