Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GitLab管道失败:未知选项:-c_Git_Gitlab_Gitlab Ci_Pipeline_Continuous Deployment - Fatal编程技术网

GitLab管道失败:未知选项:-c

GitLab管道失败:未知选项:-c,git,gitlab,gitlab-ci,pipeline,continuous-deployment,Git,Gitlab,Gitlab Ci,Pipeline,Continuous Deployment,我创建了一个管道来运行一系列作业,这些作业自动将我的应用程序部署到沙箱环境中。我对.gitlab ci.yml的配置是: stages: - pull - build pull-code-job: stage: deploy script: - cd /usr/share/nginx/html - git pull http://myuser:mypassword@mydomain.com/user/my-app.git master build-code-j

我创建了一个管道来运行一系列作业,这些作业自动将我的应用程序部署到沙箱环境中。我对
.gitlab ci.yml
的配置是:

stages:
  - pull
  - build

pull-code-job:
  stage: deploy
  script:
    - cd /usr/share/nginx/html
    - git pull http://myuser:mypassword@mydomain.com/user/my-app.git master

build-code-job:
  stage: deploy
  script:
    - npm install
    - npm run alpha
当我查看管道日志时,我总是发现它们失败了:

Unknown option: -c

我没有电话
git-c


我的os GitLab CE版本是12.0.3,使用Runner的git版本是1.7.1。

对于您定义的每个作业,与管道关联的代码将始终在运行任何脚本之前、脚本之前或脚本部分之后提取或克隆到作业环境中。如果作业应该针对存储库中的代码运行,则根本不必
git clone
git pull
;它会自动为你发生。您在作业中看到的输出来自此自动获取

如果需要,可以使用设置为“无”的
GIT_策略
变量禁用自动提取:

pull-code-job:
  stage: deploy
  variables:
    GIT_STRATEGY: none
  script:
    - cd /usr/share/nginx/html
    - git pull http://myuser:mypassword@mydomain.com/user/my-app.git master
对于此作业,不会从Gitlab获取/克隆存储库。如果在管道中有另一项工作可以提取代码,然后构建一个工件,比如npm依赖项、源代码中编译的二进制文件等,那么这将非常有用


由于您使用的是
shell
executor,因此作业直接在运行程序所在的主机上运行(而不是在Docker容器中)。查看
git用法
输出,该git版本似乎没有
-c
选项。尝试在运行
gitlab runner
ALPHA的主机上升级
git
,然后再次运行管道。

好的,我了解它的工作原理,谢谢Adam。使用GIT_策略时,不会出现错误。您知道运行程序使用哪个用户执行shell命令吗?手动拉取时,我收到一个权限被拒绝的错误:*分支主控->获取头错误:无法取消旧“.gitlab ci.yml”(权限被拒绝)更新0d43c79..f8e578b用户是gitlab运行者,权限被拒绝的错误通过以下方法解决:chmod-R g+w./html