gitlab ci php 构建,Gitlab CI如何部署PHP?

我使用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相关的例子,但没有成功.有人可以说明应该如何运作

最佳答案 尝试用sudo -Hu替换su -c

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值