OBT-SYSADM\tomishinets 6 лет назад
Родитель
Сommit
8b3100b937
1 измененных файлов с 9 добавлено и 2 удалено
  1. 9 2
      generate.sh

+ 9 - 2
generate.sh

@@ -16,11 +16,18 @@ function mail_send {
               -S from=${JENKINS_MAIL_USER} \
               ${RECIPIENT_MAIL_BOX}
 }
+
+function git_config {
+              cd /${git_dir}
+              git config --global user.email "${JENKINS_MAIL_USER}"
+              git config --global user.name "Jenkins"
+}
+
 if [ -z "$*" ]; then message="letsencrypt. No domain specified!!!"; mail_send; exit 1;fi
 
 if [ -d /${git_dir} ]
 then
-  cd /${git_dir} && git pull https://${GIT_USER}:$(cat /run/secrets/provision-pass)@${GIT_URL} && git checkout ${branch}
+  git_config && git pull https://${GIT_USER}:$(cat /run/secrets/provision-pass)@${GIT_URL} && git checkout ${branch}
   if [ $? -ne 0 ];then message="letsencrypt. Can't pull https://${GIT_URL}"; mail_send; exit 1;fi
 else
   cd / && git clone https://${GIT_USER}:$(cat /run/secrets/provision-pass)@${GIT_URL} && cd /${git_dir} && git checkout ${branch}
@@ -35,7 +42,7 @@ if [ $? -ne 0 ];then message="letsencrypt. Can't execute "dry-run" for $(echo $*
 #if [ $? -ne 0 ];then message="letsencrypt. Can't generate cert and key for $(echo $*). See log !!!"; mail_send; exit 1;fi
 
 echo "Generate new key and cert for $(echo $*)" > /tmp/commit.txt
-cd /${git_dir} && git add -A && git config --global user.email "${JENKINS_MAIL_USER}" && git config --global user.name "Jenkins" && git commit -F /tmp/commit.txt
+git_config && git add -A && git commit -F /tmp/commit.txt
 git push https://${GIT_USER}:$(cat /run/secrets/provision-pass)@${GIT_URL} ${branch}
 if [ $? -ne 0 ];then message="letsencrypt. Can't push diff to https://${GIT_URL} !!!"; mail_send; exit 1;fi