Commit 1941d39f by Yvon

revert new option target_branch as it's unfortunately not so easy to set up

parent 2c316168
Pipeline #3182 failed with stage
in 1 minute 7 seconds
...@@ -10,13 +10,11 @@ instance=$2 #(prod not supported for now) ...@@ -10,13 +10,11 @@ instance=$2 #(prod not supported for now)
shift shift
shift shift
target_branch=""
send_mails=true send_mails=true
#https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash #https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
while [[ "$#" -gt 0 ]]; do while [[ "$#" -gt 0 ]]; do
case $1 in case $1 in
-b|--branch) target_branch="$2"; shift ;;
-n|--nomail) send_mails=false ;; -n|--nomail) send_mails=false ;;
*) echo "arguments : ${coop} ${instance} $1 not supported (Unknown parameter passed: $1)" *) echo "arguments : ${coop} ${instance} $1 not supported (Unknown parameter passed: $1)"
if ${send_mails}; then if ${send_mails}; then
...@@ -35,22 +33,18 @@ if ! python3 "${ci_dir}/supported_coops.py" "${coop}" "${instance}"; then ...@@ -35,22 +33,18 @@ if ! python3 "${ci_dir}/supported_coops.py" "${coop}" "${instance}"; then
exit 1 exit 1
fi fi
if [[ -z "${target_branch}" ]]; then
target_branch="${coop}_prod"
fi
now=$( date +%Y%m%d_%H%M%S ) now=$( date +%Y%m%d_%H%M%S )
source "${ci_dir}/update_code.sh" source "${ci_dir}/update_code.sh"
repo="third-party" repo="third-party"
echo "START PROCESS" "${coop}" "${instance}" "${repo}" "${now}" "${target_branch}" echo "START PROCESS" "${coop}" "${instance}" "${repo}" "${now}"
update_code "${coop}" "${instance}" "${repo}" "${now}" "${target_branch}" "${send_mails}" || exit 1 update_code "${coop}" "${instance}" "${repo}" "${now}" "${send_mails}" || exit 1
echo "DONE" echo "DONE"
repo="Odoo" repo="Odoo"
echo "START PROCESS" "${coop}" "${instance}" "${repo}" "${now}" "${target_branch}" echo "START PROCESS" "${coop}" "${instance}" "${repo}" "${now}"
update_code "${coop}" "${instance}" "${repo}" "${now}" "${target_branch}" "${send_mails}" || exit 1 update_code "${coop}" "${instance}" "${repo}" "${now}" "${send_mails}" || exit 1
echo "DONE" echo "DONE"
if [[ "${instance}" == "preprod" ]] -a ${send_mails}; then if [[ "${instance}" == "preprod" ]] -a ${send_mails}; then
......
...@@ -4,8 +4,7 @@ update_code() { ...@@ -4,8 +4,7 @@ update_code() {
instance=$2 instance=$2
repo=$3 repo=$3
now=$4 now=$4
target_branch=$5 send_mails=$5
send_mails=$6
ci_dir="/home/django/third-party/scripts/src" ci_dir="/home/django/third-party/scripts/src"
ci_data_dir="/home/django/third-party/scripts/data" ci_data_dir="/home/django/third-party/scripts/data"
...@@ -30,12 +29,12 @@ update_code() { ...@@ -30,12 +29,12 @@ update_code() {
cd /home/${user}/${repo} cd /home/${user}/${repo}
su ${user} -c "git fetch --all" su ${user} -c "git fetch --all"
branch_found_str=$( su ${user} -c "git ls-remote origin ${target_branch}" ) #seems that git ls-remote is not "failing" so we need to check output branch_found_str=$( su ${user} -c "git ls-remote origin ${coop}_prod" ) #seems that git ls-remote is not "failing" so we need to check output
if [ -z "${branch_found_str}" ]; then if [ -z "${branch_found_str}" ]; then
#branch prod does not exist, cannot go on #branch prod does not exist, cannot go on
echo "${coop} ${instance} ${repo}: branch ${target_branch} does not exist" echo "${coop} ${instance} ${repo}: branch ${coop}_prod does not exist"
if ${send_mails}; then if ${send_mails}; then
python3 "${ci_dir}/send_error_mail.py" "${coop} ${instance} ${repo} : branch ${target_branch} does not exist" python3 "${ci_dir}/send_error_mail.py" "${coop} ${instance} ${repo} : branch ${coop}_prod does not exist"
fi fi
exit 1 exit 1
fi fi
...@@ -43,13 +42,13 @@ update_code() { ...@@ -43,13 +42,13 @@ update_code() {
###COMPARE BRANCHES AND DECIDE IF WE NEED TO CREATE A FILE CONTAINING NEW COMMITS### ###COMPARE BRANCHES AND DECIDE IF WE NEED TO CREATE A FILE CONTAINING NEW COMMITS###
#new_commits="$( git log origin/${target_branch}...origin/dev_cooperatic --no-merges --oneline )" (old version) #new_commits="$( git log origin/${coop}_prod...origin/dev_cooperatic --no-merges --oneline )" (old version)
#Let's break down the new big line below : #Let's break down the new big line below :
#origin/${target_branch}...origin/dev_cooperatic : we look for difference between develop branch and prod branch #origin/${coop}_prod...origin/dev_cooperatic : we look for difference between develop branch and prod branch
#--pretty=format:'%s' : get rid of commit id #--pretty=format:'%s' : get rid of commit id
#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 #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/${target_branch}...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' )" 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 if [ -z "${new_commits}" ]; then
echo "${coop} ${instance} ${repo} : no new commits" 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. #As there are no new commits in prod, we don't want to send email for this repo.
......
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