Skip to content

Option to disable git clone on deployment stage - GitLab CI

ZD: https://gitlab.zendesk.com/agent/tickets/35258

Proposal

Provide the ability to disable a git clone in a GitLab CI build stage.

Customer comments

We’ve just started working on using GitLab CI and Manual Deploys for pushing our apps into production environments.

In the first build step, we have set the repository to clone in the CI settings, then we run through a bunch of steps to remove files, change permissions, etc.

The “release” is then copied into a separate directory ready to RSYNC into production which used to be done by a separate BASH script.

We’ve moved that last step into the manual deploy task and everything is working great, but when the deploy step runs, it checks out the repo which we don’t need and adds extra time onto the deploy.

Is it possible to add a pre-step so that it stops the initial clone task?

Example gitlab-ci.yml configuration file

stages:
  - build
  - deploy

variables:
  RELEASES: "/export/releases"
  WWW_MASTER: "www.website.com"

build_master:
  stage: build
  script:
  - echo "Copying from $CI_PROJECT_DIR/ to $RELEASES/$WWW_MASTER"
  - sudo /usr/bin/rsync -atq --delete $CI_PROJECT_DIR/ $RELEASES/$WWW_MASTER
  - sudo rm -r $RELEASES/$WWW_MASTER/.git
  - sudo rm $RELEASES/$WWW_MASTER/.gitlab-ci.yml
  - sudo find $RELEASES/$WWW_MASTER -type d -exec chmod 755 {} \;
  - sudo find $RELEASES/$WWW_MASTER -type f -exec chmod 644 {} \;
  - sudo chown -R root:root $RELEASES/$WWW_MASTER
  only:
  - master

deploy_master:
  stage: deploy
  script:
  - sudo /usr/bin/rsync -atq --delete -e "ssh -o LogLevel=ERROR" $RELEASES/$WWW_MASTER root@IP:/var/www
  environment: production
  when: manual

Related links: