Is there a 'getScriptPath()' equivalent for workflow pipeline?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there a 'getScriptPath()' equivalent for workflow pipeline?

pallen
Hi Guys,

With MultiBranch I can access the name of the Jenkinsfile script path from SCMSourceOwner()  e.g.

public String getScriptPathOrDefault() {
SCMSourceOwner owner = getOwner();
if (owner instanceof WorkflowMultiBranchProject) {
WorkflowMultiBranchProject branchProject = (WorkflowMultiBranchProject) owner;
WorkflowBranchProjectFactory branchProjectFactory = (WorkflowBranchProjectFactory) branchProject.getProjectFactory();
return branchProjectFactory.getScriptPath();
}
return "Jenkinsfile";
}

However from a Pipeline (workflow) I'm unable to find any way to access the name of the Jenkinsfile Script.

Ideally I would like to know the value during an SCM.checkout(...) perhaps via Run<?,?> run, probably from WorkflowJob or something.


Kind regards,
Paul

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/373b7324-fcf5-4e5b-9f6d-2b6cdf1a30d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Is there a 'getScriptPath()' equivalent for workflow pipeline?

Steven Foster
Looking at a script I wrote ages ago to parse a bunch of Jenkinsfiles, something like

FlowDefinition definition = job.getDefinition()
scriptPath = ((CpsScmFlowDefinition) definition).getScriptPath()

might point you in the right direction?

On Tuesday, February 12, 2019 at 4:54:30 PM UTC, pallen wrote:
Hi Guys,

With MultiBranch I can access the name of the Jenkinsfile script path from SCMSourceOwner()  e.g.

public String getScriptPathOrDefault() {
SCMSourceOwner owner = getOwner();
if (owner instanceof WorkflowMultiBranchProject) {
WorkflowMultiBranchProject branchProject = (WorkflowMultiBranchProject) owner;
WorkflowBranchProjectFactory branchProjectFactory = (WorkflowBranchProjectFactory) branchProject.getProjectFactory();
return branchProjectFactory.getScriptPath();
}
return "Jenkinsfile";
}

However from a Pipeline (workflow) I'm unable to find any way to access the name of the Jenkinsfile Script.

Ideally I would like to know the value during an SCM.checkout(...) perhaps via Run<?,?> run, probably from WorkflowJob or something.


Kind regards,
Paul

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/3adde92f-3419-4ba4-9bfc-3e736b5b6ba9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Is there a 'getScriptPath()' equivalent for workflow pipeline?

pallen
Thank you; just what I was looking for.  I used...

((WorkflowRun) run).getParent().getDefinition().getScriptPath()

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/13678084-b405-4a27-8d77-b803d318e235%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.