Commit 487bdd8f by Yvon

5554 deploiement script fix : erase content of diff_last file when no difference…

5554 deploiement script fix : erase content of diff_last file when no difference between prod and dev_cooperatic so that previous diff_last file content is not in the mail
parent 76c59663
Pipeline #3203 failed with stage
in 1 minute 5 seconds
......@@ -42,6 +42,11 @@ update_code() {
###COMPARE BRANCHES AND DECIDE IF WE NEED TO CREATE A FILE CONTAINING NEW COMMITS###
#initialize file
if ! test -f "${ci_data_dir}/ci_diff_${repo}_last.txt"; then
touch "${ci_data_dir}/ci_diff_${repo}_last.txt"
fi
#new_commits="$( git log origin/${coop}_prod...origin/dev_cooperatic --no-merges --oneline )" (old version)
#Let's break down the new big line below :
......@@ -50,14 +55,16 @@ update_code() {
#the big grep+sed group : discard lines not maching pattern "merge [0-9]\+-... into dev_cooperatic" and only keep the [0-9]\+-.... part with a link to redmine
new_commits="$( git log origin/${coop}_prod...origin/dev_cooperatic --merges --oneline --pretty=format:'%s' | grep "into 'dev_cooperatic'" | sed "s/Merge branch '//g" | sed "s/' into 'dev_cooperatic'//g" | grep "^[0-9]\+" | sed -E 's/(^[0-9]+)/\<a href=\"https\:\/\/redmine.coopdev.fr\/issues\/\1\"\>\1\<\/a\>/g' )"
if [ -z "${new_commits}" ]; then
echo "${coop} ${instance} ${repo} : no new commits"
#As there are no new commits in prod, we don't want to send email for this repo.
#To indicate that, we do not create any ci_diff file at current time.
else
if ! test -f "${ci_data_dir}/ci_diff_${repo}_last.txt"; then
touch "${ci_data_dir}/ci_diff_${repo}_last.txt"
echo "${coop} ${instance} ${repo} : no difference between prod and dev_cooperatic"
#There are no difference between prod and dev_cooperatic therefore we don't want to send email for this repo.
#To inform the mailer that there is nothing new, we do not create ci_diff file at current time.
#The mailer will therefore use ci_diff_last to get the list of commits for the client.
#Not only there is nothing new, but also there is just no difference,
#therefore we need to erase the content the ci_diff_last file if not already empty (save time of first time it was erased)
if [[ -s "${ci_data_dir}/ci_diff_${repo}_last.txt" ]]; then
> "${ci_data_dir}/ci_diff_${repo}_last.txt"
fi
else
echo "${new_commits}" > "${ci_data_dir}/ci_diff_${repo}_${now}.txt"
#See if commit difference is the same than last time
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment