Home > Enterprise >  If statement in build using ymal aws
If statement in build using ymal aws

Time:04-24

Hey I'm trying to do an if statement in Yaml, something like if $NUMBER_OF_SOURCES == 3 then echo 1 (echo 1 will change I the future to a script that does something in aws ) what's the correct syntax? is it even possible? Hey I'm trying to do an if statement in Yaml, something like this: if

$NUMBER_OF_SOURCES == 3 then echo 1 

(echo 1 will change I the future to a script that does something in aws ), what's the correct syntax? is it even possible? tried to do something like that but i get

      - if [ $NUMBER_OF_SOURCES -eq 3 ]
      - then
        - echo "true"
      - fi

[Container] 2022/04/24 10:35:36 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: if [ $NUMBER_OF_SOURCES -eq 3 ]. Reason: exit status 2

CodePudding user response:

You do this using pipe (|) notation in yaml:

      - |
        if [ $NUMBER_OF_SOURCES -eq 3 ]
        then
          echo "true"
        fi

or just put everything in one line:

      - if [ $NUMBER_OF_SOURCES -eq 3 ]; then echo "true"; fi
  • Related