Loading .gitlab-ci.yml +9 −2 Original line number Diff line number Diff line Loading @@ -53,12 +53,19 @@ sync: stage: sync variables: GIT_STRATEGY: "none" only: variables: - $GIT_PUSH_URL =~ /^\S+$/ - $GIT_PUSH_BRANCH =~ /^\S+$/ - ($GIT_PUSH_LOGIN =~ /^\S+$/ && $GIT_PUSH_PASSWORD =~ /^\S+$/) || $SSH_PULL_PRIVATE_KEY=~ /^\S+$/ - $GIT_PULL_URL =~ /^\S+$/ - $GIT_PULL_BRANCH =~ /^\S+$/ before_script: - git config --global credential.helper store && touch ~/.git-credentials - ( test -n "${GIT_PULL_LOGIN}" && test -n "${GIT_PULL_PASSWORD}" ) && echo "https://${GIT_PULL_LOGIN}:${GIT_PULL_PASSWORD}@$(echo ${GIT_PULL_URL} | sed -r 's#([^/])/[^/].*#\1#' | sed -e 's|https://||g')" >> ~/.git-credentials || true - ( test -n "${GIT_PUSH_LOGIN}" && test -n "${GIT_PUSH_PASSWORD}" ) && echo "https://${GIT_PUSH_LOGIN}:${GIT_PUSH_PASSWORD}@$(echo ${GIT_PUSH_URL} | sed -r 's#([^/])/[^/].*#\1#' | sed -e 's|https://||g')" >> ~/.git-credentials || true - ( eval $(ssh-agent -s); echo "$SSH_PULL_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true - ( eval $(ssh-agent -s); echo "$SSH_PUSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true - ( eval $(ssh-agent -s); echo "${SSH_PULL_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true - ( eval $(ssh-agent -s); echo "${SSH_PUSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true script: - git clone "${GIT_PUSH_URL}" /tmp/repo && cd /tmp/repo && git checkout "${GIT_PUSH_BRANCH}" - git remote add upstream "${GIT_PULL_URL}" && git pull --ff-only upstream "${GIT_PULL_BRANCH}" Loading Loading
.gitlab-ci.yml +9 −2 Original line number Diff line number Diff line Loading @@ -53,12 +53,19 @@ sync: stage: sync variables: GIT_STRATEGY: "none" only: variables: - $GIT_PUSH_URL =~ /^\S+$/ - $GIT_PUSH_BRANCH =~ /^\S+$/ - ($GIT_PUSH_LOGIN =~ /^\S+$/ && $GIT_PUSH_PASSWORD =~ /^\S+$/) || $SSH_PULL_PRIVATE_KEY=~ /^\S+$/ - $GIT_PULL_URL =~ /^\S+$/ - $GIT_PULL_BRANCH =~ /^\S+$/ before_script: - git config --global credential.helper store && touch ~/.git-credentials - ( test -n "${GIT_PULL_LOGIN}" && test -n "${GIT_PULL_PASSWORD}" ) && echo "https://${GIT_PULL_LOGIN}:${GIT_PULL_PASSWORD}@$(echo ${GIT_PULL_URL} | sed -r 's#([^/])/[^/].*#\1#' | sed -e 's|https://||g')" >> ~/.git-credentials || true - ( test -n "${GIT_PUSH_LOGIN}" && test -n "${GIT_PUSH_PASSWORD}" ) && echo "https://${GIT_PUSH_LOGIN}:${GIT_PUSH_PASSWORD}@$(echo ${GIT_PUSH_URL} | sed -r 's#([^/])/[^/].*#\1#' | sed -e 's|https://||g')" >> ~/.git-credentials || true - ( eval $(ssh-agent -s); echo "$SSH_PULL_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true - ( eval $(ssh-agent -s); echo "$SSH_PUSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true - ( eval $(ssh-agent -s); echo "${SSH_PULL_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true - ( eval $(ssh-agent -s); echo "${SSH_PUSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null && mkdir -p ~/.ssh && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config ) || true script: - git clone "${GIT_PUSH_URL}" /tmp/repo && cd /tmp/repo && git checkout "${GIT_PUSH_BRANCH}" - git remote add upstream "${GIT_PULL_URL}" && git pull --ff-only upstream "${GIT_PULL_BRANCH}" Loading