我有一个 yaml 文件,我需要是否发送真实消息 yaml 文件将成功。否则 yaml 文件将失败
我想要那个,如果响应消息是真的 yaml 文件成功但否则 yaml 文件将失败
variables:
NUGET_PATH: 'C:ToolsNugetnuget.exe'
MSBUILD_PATH: 'C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildCurrentBinamd64msbuild.exe'
SOLUTION_PATH: 'Textbox_ComboBox.sln'
stages:
- build
- job1
- job2
before_script:
- "cd Source"
build_job:
stage: build
except:
- schedules
script:
- '& "$env:NUGET_PATH" restore'
- '& "$env:MSBUILD_PATH" "$env:SOLUTION_PATH" /nologo /t:Rebuild /p:Configuration=Debug'
job1:
stage: job1
script:
- 'curl adress1'
- - if [ "$message" == "SAP transfer started. Please check in db" ]; then exit 0; else exit 1; fi
job2:
stage: trigger_SAP_service
when: delayed
start_in: 5 minutes
only:
- schedules
script:
- 'curl adress2'
我希望输出工作成功。如果消息是 SAP Transfer started. Please check in db.But else yaml file failed.有人可以提供正确的语法吗? gitlabci 中的条件(if-else、for 循环)是否有任何文档?
One option would be to use an external script file which you can then call from your CI configuration by just invoking
./path/to/myscript.sh
. The benefit is that you do not have to worry about YAML syntax anymore.If you prefer to stay within the
.gitlab-ci.yml
file, I believe the following would work:I.e. you should use double quotes for your script lines and single quotes for string within those scripts. Also, the line should start with only one
-
character.