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

Environment Variable String Interpolation for Setting Custom Workspace

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I am using a multibranch pipeline in Jenkins and I need to set the name of the custom workspace directory dynamically based on the branch name. When I define the custom workspace for the pipeline, I attempt to access the environment variable that contains the branch name as follows:

      pipeline {

        agent {

          node {

            label 'master'

            customWorkspace 'some/path/${BRANCH_NAME}'

       

      However, during git init of the workspace, the string interpolation does not happen. Instead of inserting whatever the branch name is into the string, it tries to set the workspace name as '${BRANCH_NAME}' without interpolating the branch name variable. I'm not sure if this is a mistake on my end or if it's a bug, so feel free to close if it's intended behavior. Thanks!

        Attachments

          Activity

          Hide
          raihaan Raihaan Shouhell added a comment -

          Does this not work with double quoted strings i.e "" instead of ''

          Show
          raihaan Raihaan Shouhell added a comment - Does this not work with double quoted strings i.e "" instead of ''
          Hide
          shenoyprath Prathamesh Shenoy added a comment - - edited

          Raihaan Shouhell Yup. This works when double quotes are used. Thanks!

           

          It's weird because single quotes work everywhere else for interpolation. Might be a bug. Will close the issue for now.

          Show
          shenoyprath Prathamesh Shenoy added a comment - - edited Raihaan Shouhell Yup. This works when double quotes are used. Thanks!   It's weird because single quotes work everywhere else for interpolation. Might be a bug. Will close the issue for now.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            shenoyprath Prathamesh Shenoy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: