jeudi 3 octobre 2019

How to read json file in gitlab ci yaml and use if else command?

I have a yaml file and I have a respond for yaml file.Respond file have a message part.and I need if message is true return Job Succeed for yaml file if message writes wrong yaml file is not succeed

variables: NUGET_PATH: 'C:\Tools\Nuget\nuget.exe' MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\amd64\msbuild.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'

It is yaml file respond.It should be job succeed.Because respond message and if command message is same.

Running with gitlab-runner 12.2.0 (v12.2.0) on ikarus08 fd481fc2 Using Docker executor with image docker.siemens.com/ccp/vm:stable ... WARNING: Container based cache volumes creation is disabled. Will not create volume for "/cache" Authenticating with credentials from job payload (GitLab Registry) Pulling docker image docker.siemens.com/ccp/vm:stable ... Using docker image sha256:c993bcef0a78f9478b7c13d3b4b091292c69ff9fb1b20639b3ef03b0c5a32f8a for docker.siemens.com/ccp/vm:stable ... Running on runner-fd481fc2-project-77708-concurrent-0 via ikarus08... Fetching changes with git depth set to 50... Initialized empty Git repository in /builds/onurcan.simsek/projectexample/.git/ Created fresh repository. From https://code.siemens.com/onurcan.simsek/projectexample * [new branch] master -> origin/master Checking out f6fc37f8 as master...

Skipping Git submodules setup Authenticating with credentials from job payload (GitLab Registry) $ cd Source $ curl http://webapps.siemens.com.tr/dataBus/runTransfer/ctDigiTransfer % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 146 0 146 0 0 877 0 --:--:-- --:--:-- --:--:-- 879 {"status":200,"message":"SAP transfer started. Please check in db","errorCode":0,"timestamp":"2019-10-04T07:59:58.436+0300","responseObject":null}$ if ( [ '$message' == 'SAP transfer started. Please check in db' ] ); then exit 0; else exit 1; fi ERROR: Job failed: exit code 1

Aucun commentaire:

Enregistrer un commentaire