Home > Blockchain >  In a Jenkins pipeline, how can I get the current job's full name?
In a Jenkins pipeline, how can I get the current job's full name?

Time:08-28

I'm able to use this to get a job's full name

final String jobName = Jenkins.instance.getItemByFullName(JOB_NAME)

But I see this in the console when I print jobName

org.jenkinsci.plugins.workflow.job.WorkflowJob@27535488[MyJobFolder/MyJobName]

How can I get just MyJobFolder/MyJobName with a different pipeline function call? I know I can process that string to get it, but there's got to be a pipeline function already. TIA

CodePudding user response:

LOL, I've coded this before and just forgot it. It's

final String jobName = Jenkins.instance.getItemByFullName(JOB_NAME).fullName
  • Related