Answer the question
In order to leave comments, you need to log in
How to configure deploy in gitlab-ci by variable?
Greetings, is it possible to somehow run a CI task in gitlab, only on a schedule and only from the master? At the same time, do not run the task when committing to the master?
If I write:
only:
refs:
- master
- schedules
---
stages:
- prod_deploy
variables:
GITLAB_INT: gitlab01
cron_deploy:
stage: prod_deploy
only:
refs:
- master
- schedules
variables:
- $DEPLOY == "cron"
except:
changes:
- .gitlab-ci.yml
tags:
- PROD_CRON
before_script:
# Удаляем старую версию
- rm -f ${PROD_SRC}/htdocs_2.tar
# Перемещаем предыдущую версию
- mv ${PROD_SRC}/htdocs_1.tar ${PROD_SRC}/htdocs_2.tar || echo "Файла еще нет"
- tar -cpf ${PROD_SRC}/htdocs_1.tar ${PROD_SRC}/htdocs
script:
- cd ${PROD_SRC}/htdocs && git reset --hard HEAD^
- cd ${PROD_SRC}/htdocs && git checkout ${CI_COMMIT_REF_NAME} && git pull
when: always
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question