3

What is the correct formatting used to access the BRANCH_NAME variable in the file operations plugin-> file copy? The target location to be exact.

I have tried %BRANCH_NAME%, ${env.BRANCH_NAME} but jenkins keeps taking them literally and creating the directory with the same name, i.e. c:\%BRANCH_NAME%

Jenkins Version 2.72

File Operations Plugin Version 1.6

scranley
  • 188
  • 1
  • 4
  • 20

2 Answers2

1

On my installation with Jenkins 2.60.2 and File Operations Plugin 1.6, ${BRANCH_NAME} works for me.

Kdawg
  • 1,508
  • 13
  • 19
  • Does BRANCH_NAME show up in your job's environment variables? How was the job created to generate BRANCH_NAME for future reference? – scranley Aug 02 '17 at 16:48
  • 1
    @scranley For my test, I just injected an environment variable in called BRANCH_NAME (since that's what yours was called). I believe (but I'm not certain, so don't quote me on this) that when doing things like a multi-branch pipeline, the branch name is stored in the BRANCH_NAME environment variable. I'm going to assume (based on your experience) that this is not the way it's done in other project types, but yeah, GIT_BRANCH is the variable exposed by the Git plugin for the branch name. – Kdawg Aug 02 '17 at 16:56
0

BRANCH_NAME didn't exist under the build# environment variables, but GIT_BRANCH did. ${GIT_BRANCH} used as the target folder created a folder with the branch name.

scranley
  • 188
  • 1
  • 4
  • 20