mardi 19 février 2019

How to use if-else condition on gitlabci

How to use if else condition inside the gitlab-CI.

I have below code:

deploy-dev:
  image: testimage
  environment: dev
  tags:
    - kubectl
  script:
   - kubectl apply -f demo1 --record=true
   - kubectl apply -f demo2 --record=true

Now I want to add a condition something like this

script:
    - (if [ "$flag" == "true" ]; then kubectl apply -f demo1 --record=true; else kubectl apply -f demo2 --record=true);

Could someone provide the correct syntax for the same? Is there any documentation for the conditions (if-else, for loop) in gitlabci?

Aucun commentaire:

Enregistrer un commentaire