From a2ae12e2aafea9e29b60bee76c38d11a104a091f Mon Sep 17 00:00:00 2001 From: Jay Sharma Date: Sat, 26 Aug 2023 15:02:21 +0530 Subject: [PATCH] auto-patch --- common-jobs-bitbucket.sh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/common-jobs-bitbucket.sh b/common-jobs-bitbucket.sh index 28e206bc..b248870c 100644 --- a/common-jobs-bitbucket.sh +++ b/common-jobs-bitbucket.sh @@ -54,22 +54,23 @@ kubectl apply -f build/$ENV/pod.tpl && sleep 15 kubectl cp setenv.sh $NAMESPACE/common-job-pod:/tmp/setenv.sh kubectl exec common-job-pod -n $NAMESPACE -- sh -c 'chmod 755 /tmp/setenv.sh' kubectl exec common-job-pod -n $NAMESPACE -- apt update -kubectl exec common-job-pod -n $NAMESPACE -- apt install wget zip unzip curl git -y +kubectl exec common-job-pod -n $NAMESPACE -- apt install wget zip unzip curl git rsync -y # --------------------------------------------------------------------------------------------------------------------------------------------------------- -#kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; git clone https://x-token-auth:$TOKEN@bitbucket.org/connectamerica/$REPO.git' - -kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh;cd /tmp;git clone --branch="feature/inital-setup" https://x-token-auth:$TOKEN@bitbucket.org/connectamerica/$REPO.git;cd $REPO/;git config user.email "{botid}@bots.bitbucket.org" ; git checkout -b feature/$VERSION-$ENV-$SUBDOMAIN && git push --set-upstream origin feature/$VERSION-$ENV-$SUBDOMAIN; -mv /usr/share/nginx/subdomain/$SUBDOMAIN/wp-content/uploads /tmp/; -cp -rf /usr/share/nginx/subdomain/$SUBDOMAIN/* wp/; -mv /tmp/uploads /usr/share/nginx/subdomain/$SUBDOMAIN/wp-content/; +kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; +cd /tmp; +git clone --branch="develop" https://x-token-auth:$TOKEN@bitbucket.org/connectamerica/$REPO.git; +cd $REPO/; +git config user.email "{botid}@bots.bitbucket.org" ; +git checkout -b feature/$VERSION-$ENV-$SUBDOMAIN && git push --set-upstream origin feature/$VERSION-$ENV-$SUBDOMAIN; +rsync -a --exclude 'wp-content/uploads' /usr/share/nginx/subdomain/$SUBDOMAIN/ wp; git add --all && git commit -m "auto-patch $VERSION-$ENV-$SUBDOMAIN-$(date +%Y-%m-%dT%H_%M_%S)" && git push' #-------------------------------------------------------------------------------------------------------------- kubectl delete po common-job-pod -n $NAMESPACE -cat script.log | egrep -v -i "warning|SQL" | egrep -i "fail|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt +cat script.log | egrep -v -i "warning|SQL|create mode|rewrite" | egrep -i "fail|fatal|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt ;; @@ -84,7 +85,7 @@ kubectl exec common-job-pod -n $NAMESPACE -- sh -c 'chmod 755 /tmp/setenv.sh' kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh ; cp -rf /tmp/wp/* /usr/share/nginx/subdomain/$SUBDOMAIN/' echo $SUBDOMAIN | grep www && echo "maindomain $URL_DOMAIN" || kubectl delete po common-job-pod -n $NAMESPACE -cat script.log | egrep -v -i "warning|SQL" | egrep -i "fail|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt +cat script.log | egrep -v -i "warning|SQL|create mode|rewrite" | egrep -i "fail|fatal|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt ;; @@ -112,7 +113,7 @@ curl --request POST -F files=@"$FILE" --url "https://api.bitbucket.org/2.0/repo kubectl delete po common-job-pod -n $NAMESPACE -cat script.log | egrep -v -i "warning|SQL" | egrep -i "fail|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt +cat script.log | egrep -v -i "warning|SQL|create mode|rewrite" | egrep -i "fail|fatal|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt ;; @@ -129,7 +130,7 @@ kubectl cp $NAMESPACE/common-job-pod:/tmp/upload.zip $NAMESPACE-$VERSION-$ENV-$S FILE=`ls $NAMESPACE-*.zip` aws s3 cp $FILE s3://commonjobs/$NAMESPACE/$opt/ kubectl delete po common-job-pod -n $NAMESPACE -cat script.log | egrep -v -i "warning|SQL" | egrep -i "fail|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt +cat script.log | egrep -v -i "warning|SQL|create mode|rewrite" | egrep -i "fail|fatal|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt ;; @@ -177,7 +178,7 @@ kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; wp search- kubectl delete po common-job-pod -n $NAMESPACE -cat script.log | egrep -v -i "warning|SQL" | egrep -i "fail|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt +cat script.log | egrep -v -i "warning|SQL|create mode|rewrite" | egrep -i "fail|fatal|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt ;; wp-data-restore) @@ -197,7 +198,7 @@ kubectl cp $FILE $NAMESPACE/common-job-pod:/tmp/$FILE kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; mkdir -p /usr/share/nginx/subdomain/$SUBDOMAIN/wp-content/uploads' kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh;export FILE=`ls /tmp/*.zip`;unzip -o $FILE -d /usr/share/nginx/subdomain/$SUBDOMAIN/wp-content/uploads' kubectl delete po common-job-pod -n $NAMESPACE -cat script.log | egrep -v -i "warning|SQL" | egrep -i "fail|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt +cat script.log | egrep -v -i "warning|SQL|create mode|rewrite" | egrep -i "fail|fatal|exception|terminated|command not found|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt ;;