Declarative Pipeline: Allow env vars to be used in options block

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      I'm trying to use the lock() option in an options block of a stage. I want the lock resource to be dynamic (depending on an environment variable).

      For example:

          environment  {
              BRANCH_TO_USE = get_branch_to_use()
          }
      stages {
          stage('Lock build'){
              options {
                lock(resource: "lock-${env.BRANCH_TO_USE}", quantity: 1)
              }
              stages {
      ...
      

      But the resulting string is always "lock-null". I tried it without "env." but to no avail.

      I would expect this to work especially since the environment variable is available in the coming stages with no problem.

      Is there a way to support this or a possible workaround?

            Assignee:
            Unassigned
            Reporter:
            Marius Meyer
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: