Rancher 2 Pipeline Env Var

I’m trying to set some env var for a deployment with pipelines (Even better a config map) but at the moment, I can only set an env var for the steps.

Is possible to set env vars for a Workload in a the deployment yaml?

Yea, just add them to the deployment.yaml like this

spec:
  containers:
  - name: spring-boot-demo
    image: myrepo:443/spring-boot-demo:${CICD_EXECUTION_SEQUENCE}
    env:
      - name: APP_NAME
        value: spring-boot-demo
      - name: BOOT_ADMIN_ENABLED
        value: "true"
      - name: BOOT_ADMIN_PREFER_IP
        value: "true"
      - name: CONTEXT_PATH
        value: /spring-boot-demo
      - name: BOOT_ADMIN_URL
        valueFrom:
          configMapKeyRef:
            key: bootAdminUrl
            name: common
            optional: false

And if you want to insert values through .rancher-pipeline.yml use ${MY_VAR} in the deployment.yaml and like this in the pipeline yaml

- name: Deploy yaml
  steps:
  - applyYamlConfig:
      path: ./deployment.yaml
    env:
      MY_VAR: 236578
1 Like

I have tried the proposed solution but I was unable to replace the environment variables set in the .rancher-pipeline.yml file in the deployment.yaml file.

It only seems to work with the variables predefined by Rancher CICD_XXXXX