[JIRA] (JENKINS-44278) JOB_BASE_NAME variable showing Branch value instead of Project name

1 view
Skip to first unread message

medianick@gmail.com (JIRA)

unread,
Jul 26, 2019, 10:45:03 AM7/26/19
to jenkinsc...@googlegroups.com
Nick Jones commented on Bug JENKINS-44278
 
Re: JOB_BASE_NAME variable showing Branch value instead of Project name

I've created and successfully tested a Shared Library function with the following:

def call() {
  def jobNameParts = env.JOB_NAME.tokenize('/') as String[]
  jobNameParts.length < 2 ? env.JOB_NAME : jobNameParts[jobNameParts.length - 2]
}

This takes care of the possibility that the multibranch pipeline is nested several folders deep (per Jesse Glick's comment that this should be the penultimate – next to last – token).

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)
Reply all
Reply to author
Forward
0 new messages