I’m starting with Gitlab and gitlab CI and my first gitlab-ci is not working as expecting :
I created 3 jobs in 3 differents stages to :
1° create a file
2° modify the file
3° test the content of the file
1° and 2° are doing what I expect but the file tested in step3 seems to be the empty file created in 1° and not the file modified in step 2°.
My gitlab-ci.yaml :
stages:
- prep
- build
- test
prepare the car:
stage: prep
script:
- mkdir build
- cd build
- touch car.txt
artifacts:
paths:
- build/
build the car:
stage: build
script:
- cd build
- echo “Chassis” >> car.txt
- echo “Engine” >> car.txt
- echo “Wheels” >> car.txt
- cat car.txt
artifacts:
paths:
- build/
test the car:
stage: test
script:
- ls
- test -f build/car.txt
- cd build
- grep “Chassis” car.txt
- grep “Engine” car.txt
- grep “Wheels” car.txt
I also tried to not declare again the artifacts in the ‘build the car’ job but the result is still the same : ‘test the car’ failed at grep "Chassis" car.txt
because car.txt is empty.
Thanks by advance.