VARIABLES GITLAB CI/CD kubectl – Stack Overflow

i have this gitlab-ci.yml



stages:
  - lang
  - db

variables:
  repo: "cidcd-runner"
  dir: "/var/www/html/moodle/report/"
  KUBE: $(kubectl get ns | awk -F ' ' '{print $1}' | grep -vE 'NAME|default|kube-node-lease|kube-public|kube-system')

job-lang:
  stage: lang
  script:
    - for i in $(kubectl get ns | awk -F ' ' '{print $1}' | grep -vE 'NAME|default|kube-node-lease|kube-public|kube-system'); do
        if [ -z $(kubectl exec cron-$i-0 -n $i -- ls -l $dir | grep $repo | awk -F " " '{print ($NF)}') ]; then
          echo NO esta en $i;
        else 
          echo esta en $i;
        fi;
      done
  tags:
    - onlytest

i want use varibakle KUBE in for, but when i exceute pipiline i have this error

$ for i in $kube; do if [ -z $(kubectl exec cron-$i-0 -n $i -- ls -l $dir | grep $repo | awk -F " " '{print ($NF)}') ]; then echo NO esta en $i; else echo esta en $i; fi; done
Error from server (NotFound): namespaces "`kubectl" not found
NO esta en `kubectl
Error from server (NotFound): namespaces "get" not found
NO esta en get
Error from server (NotFound): namespaces "ns" not found
NO esta en ns
Error from server (NotFound): namespaces "|" not found


How i can use variable inside for

Read more here: Source link