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

Environment Variable String Interpolation for Setting Custom Workspace

      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!

          [JENKINS-63972] Environment Variable String Interpolation for Setting Custom Workspace

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

          Raihaan Shouhell added a comment - Does this not work with double quoted strings i.e "" instead of ''

          Prathamesh Shenoy added a comment - - edited

          raihaan 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.

          Prathamesh Shenoy added a comment - - edited raihaan 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.

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

              Created:
              Updated:
              Resolved: