[英]Cleaning up project directory and file based variables 00:01 ERROR: Job failed: exit code 1
I started learning gitlab-ci using a course on udemy.我开始使用 udemy 上的课程学习 gitlab-ci。 Below code is absolutely similar to the master's code but his code run correctly but my code release error.下面的代码与大师的代码绝对相似,但他的代码运行正确但我的代码发布错误。 what is wrong with below code:下面的代码有什么问题:
stages:
- build
- test
build the car:
stage: build
script:
- mkdir build
- touch car.txt
- echo "chassis" >> car.txt
- echo "engine" >> car.txt
- echo "wheels" >> car.txt
artifacts:
paths:
- build/
test the car:
stage: test
script:
- ls
- test -f build/car.txt
- cd build
- ls
- cat car.txt
- grep "chassis" car.txt
- grep "engine" car.txt
- grep "wheels" car.txt
[:[error][1]][1] [1]: https.//i.stack.imgur.com/dWGiY.png [:[错误][1]][1][1]: https.//i.stack.imgur.com/dWGiY.png
You are creating the build
directory but your car.txt
is at the root folder, therefore not part of the artifact and not existing in the test stage.您正在创建build
目录,但您的car.txt
位于根文件夹中,因此不是工件的一部分,也不存在于测试阶段。
Your structure now:你现在的结构:
.
├── /build
├── car.txt
How it should be应该如何
.
├── /build
│ └── car.txt
You should refactor all car.txt
related commands to build/car.txt
.您应该将所有与car.txt
相关的命令重构为build/car.txt
。
If you are doing an udemy course, you might wanna have a look at variables so that you can assign the filepath to a variable and don't run into problems if you need to relate to the same path in different commands.如果您正在上 udemy 课程,您可能想查看变量,以便可以将文件路径分配给变量,并且如果您需要在不同命令中关联相同路径,则不会遇到问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.