I started learning gitlab-ci using a course on udemy. 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
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.
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
.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.