Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.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-ci.yml未执行shell脚本_Shell_Continuous Integration_Yaml_Sh_Gitlab - Fatal编程技术网

gitlab-ci.yml未执行shell脚本

gitlab-ci.yml未执行shell脚本,shell,continuous-integration,yaml,sh,gitlab,Shell,Continuous Integration,Yaml,Sh,Gitlab,我为我的项目设置了gitlab ci,并插入了以下yml脚本: --- buildJob: only: - master script: - "sh /var/www/gitTestFolder/scripts/build.sh" stage: build tags: - ipsenh deployJob: only: - master script: - "sh /var/www/gitTestFolder/scr

我为我的项目设置了gitlab ci,并插入了以下yml脚本:

--- 
buildJob: 
  only: 
    - master
  script: 
    - "sh /var/www/gitTestFolder/scripts/build.sh"
  stage: build
  tags: 
    - ipsenh
deployJob: 
  only: 
    - master
  script: 
    - "sh /var/www/gitTestFolder/scripts/deploy.sh"
  stage: deploy
  tags: 
    - ipsenh
testJob: 
  only: 
    - master
  script: 
    - "sh /var/www/gitTestFolder/scripts/test.sh"
  stage: test
  tags: 
    - ipsenh
stages: 
  - build
  - test
  - deploy
此脚本在我的gitlab服务器中运行,并显示应执行脚本的终端
(/var/www../script.sh)

以下是我的一项工作的结果:

gitlab-ci-multi-runner 0.6.2 (3227f0a)
Using Shell executor...
Running on ipsenh...

Cloning repository...
Cloning into 'builds/05d0538a/0/root/ipsenh'...
Checking out 4288f64a as master...

$ sh /var/www/gitTestFolder/scripts/deploy.sh

Build succeeded.
但是,脚本永远不会执行。如果在服务器上本地执行此脚本,它将创建一个具有简单文本输出的文件。但是,它从不通过此作业创建文件

  • 脚本内容:

    echo“job executed”>>job.log

我有错误的设置吗?很明显,它的语法和权限是不正确的,否则我会得到一个错误


这会是什么?谢谢

脚本的当前目录是脚本运行时shell所在的目录,而不是脚本所在的目录

因此,
echo“job executed”>>job.log
将在shell会话的当前目录中创建一个
job.log
文件,而不是在脚本文件所在的目录中


如果要使用本地路径表示脚本文件的目录,则需要查看和。

能否显示该脚本的内容?脚本将在当前目录中创建
job.log
。如果您先使用
cd
,则当前目录位于
cd
ed要访问的位置。如果你不这样做,默认情况下,它就在你所在的任何地方。因此,您可能只是没有在正确的位置查找文件。为输出使用完整路径。这就是问题所在?你只是没有在正确的目录中查找文件?