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

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

    Details

    • Type: Improvement
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: pipeline
    • Labels:
      None
    • Similar Issues:

      Description

      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?

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              mariusmeyer Marius Meyer
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: