Reputation: 533
Another Gitlab tear-your-hair-out-session. Have summarized the problem in it's simplest form.
Local script runs correctly
#!/usr/bin/env bash
echo $CI_COMMIT_MESSAGE | grep "TO_DEV" ; searchDEV=$? ; echo $searchDEV ;
echo $CI_COMMIT_MESSAGE | grep "TO_TEST" ; searchTEST=$? ; echo $searchTEST ;
Output is
▶ CI_COMMIT_MESSAGE="jjj TO_DEV jjj" ./tst.sh
jjj TO_DEV jjj
0
1
On Gitlab we have the following ....
setUp-Destination-job:
image: localhost:6000/s3Bin/debian_slim_image:latest
stage: build
when: always
script:
- echo $CI_COMMIT_MESSAGE | grep "TO_DEV" ; searchDEV=$? ; echo $searchDEV ;
- echo $CI_COMMIT_MESSAGE | grep "TO_TEST" ; searchTEST=$? ; echo $searchTEST ;
Gitlab stubbornly just does not do the same thing. It's running bash because the image has it. Been stuck here for 2 days. Worse still it's linter is really poor. And it just fails with "exit 1". No helpful error message or anything. Gitlab CI/CD is really poor with developer productivity. Why should any developer have to spend this much time to get this working ?
Unless, I have stumbled upon something really weird to do with $? being - ha! ha! clutching straws is what I have been reduced to. Because gitlab seems to find "TO_DEV" but has a problem even running "TO_TEST" - it should return the NOT_FOUND return code of 1. But, it does not !!!
$ echo $CI_COMMIT_MESSAGE | grep "TO_DEV" ; searchDEV=$? ; echo $searchDEV ;
xxx TO_DEV xxx using preBuildJob
0
$ echo $CI_COMMIT_MESSAGE | grep "TO_TEST" ; searchTEST=$? ; echo $searchTEST ;
Running after_script 00:01
Running after script...
$ echo "Hello from after_script:" ;
Hello from after_script:
ERROR: Job failed: exit code 1
Upvotes: 1
Views: 418
Reputation: 1323783
You can start by checking:
So, first:
- script:
- echo $CI_COMMIT_MESSAGE | grep "TO_DEV" ; searchDEV=$? ; echo $searchDEV ;
- echo $CI_COMMIT_MESSAGE
Second:
- script:
- bash -c 'echo $CI_COMMIT_MESSAGE | grep "TO_DEV" ; searchDEV=$? ; echo $searchDEV ;'
Upvotes: 0