title: Referencing Environment Variable in Serverless.yml File from jenkinsfile
body: <p>I am trying to reference variables that are set in my jenkinsfile in my serverless.yml file. </p>
  
  <p>In jenkinsfile i have this </p>
  
  <pre><code>environment {
     HELLO = 'hello-world'
   }
  </code></pre>
  
  <p>In serverless.yml file i have this </p>
  
  <pre><code>custom:
    secret: ${env:HELLO}
  </code></pre>
  
  <p>When running jenkins pipeline i get this error </p>
  
  <pre><code>A valid environment variable to satisfy the declaration 'env:HELLO' could not be found.
  </code></pre>
  
  <p>Here is my full jenkins file as requested, end goal i want to use val1 and val2 and env variables but if i can figure out how to to with hello world it is the same thing.</p>
  
  <pre><code>import com.lmig.intl.cloud.jenkins.exception.BuildException
  
  def getJobName() {
     return env.JOB_NAME
  }
  
  environment {
     HELLO = 'hello-world'
  
   }
  
  def getEnvironment() {
  
     def jobName = getJobName().split('/')
     def environment = jobName[1].toLowerCase()
     return environment.toLowerCase()
  }
  
  node('linux'){
  
    stage('Checkout'){
        checkout scm
    }
    stage('Pull Secrets From Vault'){
       withAWS(credentials:'aws-cred'){
          def secret = vaultPullSecrets(app:"sls-auxiliary-service",appenv:"nonprod",runtime:'nonprod',keys:'["saslusername","saslpassword"]')
          def val1 = new groovy.json.JsonSlurper().parseText(secret)[0].SASLUSERNAME
          def val2 = new groovy.json.JsonSlurper().parseText(secret)[1].SASLPASSWORD
          if(val1 != '' &amp;&amp; val2 != ''){
              echo "Vault Secret pulled Successfully"
          }else{
              echo "Vault Secret Not Found"
              throw new BuildException("Vault Secret Not Found")
          }
       }
    }
    stage('Deploy') {
          def ENVIRONMENT = getEnvironment().replaceAll("\\_","")
          withAWS(credentials:'aws-cred') {
               sh 'npm i serverless-python-requirements'
               sh 'npm install --save-dev serverless-step-functions'
               sh 'npm install serverless-deployment-bucket --save-dev'
               sh 'npm i serverless-pseudo-parameters'
               sh 'npm i serverless-plugin-resource-tagging'
               sh 'pip3 install --user -r requirements.txt'
               sh "serverless deploy --stage ${ENVIRONMENT}"
          }
    }
  
  } 
  </code></pre>