Need help
I am studying bash and gitlab
can't get it to work
gitlab pipeline .gitlab-ci.yml
variables:
var1: test1
var2: test2
stages:
- build
build-job:
stage: build
script:
- |
bash -s << EOF
#!/bin/bash
test1 () {
echo $var1
test3=$var1
}
test2 () {
test1
echo $var2
echo $test3
}
test2
EOF
'''
Got incorrect answer
'''
Executing "step_script" stage of the job script 00:00
$ bash -s << EOF # collapsed multi-line command
test1
test2
Job succeeded
lost variable test3
'''
Just the same bash script test.sh
#!/bin/bash
test1 () {
echo $var1
test3=$var1
}
test2 () {
test1
echo $var2
echo $test3
}
test2
'''
$export var1=test1 $export var2=test2
$sh test.sh
got nice answer This is correct:
test1 test2 test1
but yaml construction has lost variable test3 between functions
I know about run test.sh from gitlab ci, but i need to run it in yaml as text How i can do it?
Thank you