Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62990

kubernetes-plugin not understanding env variable in declarative pipeline

XMLWordPrintable

      I'm trying to parametrize the yamlFile with a env variable based on the branch I'm building. What I have right now is:
       

      pipeline {
        environment {
          MASTER_BRANCH = "origin/dev"
          BUILD_POD = "${env.GIT_BRANCH == env.MASTER_BRANCH ? 'jenkins/build-pod-prod.yaml' : 'jenkins/build-pod.yaml' }"
        }
        agent {
          kubernetes {
            idleMinutes 3
            yamlFile env.BUILD_POD
            defaultContainer 'docker'
          }
        }
      }
      

      But that is taking a default template with just the jnlp container. I've tried also putting:

      yamlFile env.BUILD_POD
      yamlFile "${env.BUILD_POD}"
      yamlFile "${BUILD_POD}"
      yamlFile "$BUILD_POD"
      yamlFile $BUILD_POD
      

      But none of that worked. I don't know if it's some misunderstanding from my side or a bug.

      Thanks all in advance.

            Unassigned Unassigned
            alesanchez Ale Sanchez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: