Gitlab CI如何部署PHP?

时间:2016-06-06 08:42:24

标签: php deployment gitlab gitlab-ci

我使用gitlab,gitab-ci和我对Continuous Integration来说相当新鲜。我尝试在代码推送上测试和部署bash脚本。

我的.gitlab-ci.yml在部署的哪个方面我试图改变用户但不会工作

before_script:
  - composer install --prefer-dist > /dev/null

stages:
  - build
  - test
  - deploy


unitTesting:
  stage: test
  script:
    - echo "Running PHPUnit Tests"
    - php vendor/bin/phpunit --colors --debug  --coverage-text

job_deploy_master:
  stage: deploy
  only:
    - master
  script:
    - /bin/su - myuser -c "deploy.sh" //here I try to change linux user to be able to checkout code but fails with  **su: must be run from a terminal**
  tags:
    - php

在这里我有bash,如果测试正在通过,它应该在生产站点上提取代码

#!/bin/bash

echo "Starting Deploy"
printf '%s\n' "${SUDO_USER:-$USER}" //I'm interested to see which user try to run this script outputs gitlab-runner
cd /home/builds/gpx-convertor
git pull
composer install --prefer-dist > /dev/null

我试图谷歌找到一些与PHP相关的例子,但没有成功。有人可以说明应该如何运作

1 个答案:

答案 0 :(得分:1)

尝试用sudo -Hu替换su -c