-
New Feature
-
Resolution: Unresolved
-
Minor
-
None
I want to be able to access parent job/build from my pipeline, unfortunately it throws an error.
import org.jenkinsci.plugins.workflow.job.WorkflowJob import org.jenkinsci.plugins.workflow.job.WorkflowRun WorkflowJob ParentJob WorkflowRun ParentBuild pipeline { agent any stages { stage('Run') { steps { script { def cause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) if (cause == null) { currentBuild.result = 'ABORTED' error("Unknown parent build or current build was triggered by user directly.") } def parentJob = hudson.model.Hudson.instance.getItem(cause.upstreamProject) def parentBuild = parentJob.getBuildByNumber(cause.upstreamBuild) ParentJob = parentJob ParentBuild = parentBuild } } } } }
[JENKINS-48508] Storing parent job/build in property
Description |
Original:
I want to be able to access parent job/build from my pipeline, unfortunately it throws an error. import org.jenkinsci.plugins.workflow.job.WorkflowJob import org.jenkinsci.plugins.workflow.job.WorkflowRun WorkflowJob ParentJob WorkflowRun ParentBuild pipeline \{ agent any stages \{ stage('Run') \{ steps \{ def cause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) if (cause == null) \{ currentBuild.result = 'ABORTED' error("Unknown parent build or current build was triggered by user directly.") } def parentJob = hudson.model.Hudson.instance.getItem(cause.upstreamProject) def parentBuild = parentJob.getBuildByNumber(cause.upstreamBuild) ParentJob = parentJob ParentBuild = parentBuild } } } } |
New:
I want to be able to access parent job/build from my pipeline, unfortunately it throws an error. {code:java} import org.jenkinsci.plugins.workflow.job.WorkflowJob import org.jenkinsci.plugins.workflow.job.WorkflowRun WorkflowJob ParentJob WorkflowRun ParentBuild pipeline { agent any stages { stage('Run') { steps { def cause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) if (cause == null) { currentBuild.result = 'ABORTED' error("Unknown parent build or current build was triggered by user directly.") } def parentJob = hudson.model.Hudson.instance.getItem(cause.upstreamProject) def parentBuild = parentJob.getBuildByNumber(cause.upstreamBuild) ParentJob = parentJob ParentBuild = parentBuild } } } } {code} |
Description |
Original:
I want to be able to access parent job/build from my pipeline, unfortunately it throws an error. {code:java} import org.jenkinsci.plugins.workflow.job.WorkflowJob import org.jenkinsci.plugins.workflow.job.WorkflowRun WorkflowJob ParentJob WorkflowRun ParentBuild pipeline { agent any stages { stage('Run') { steps { def cause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) if (cause == null) { currentBuild.result = 'ABORTED' error("Unknown parent build or current build was triggered by user directly.") } def parentJob = hudson.model.Hudson.instance.getItem(cause.upstreamProject) def parentBuild = parentJob.getBuildByNumber(cause.upstreamBuild) ParentJob = parentJob ParentBuild = parentBuild } } } } {code} |
New:
I want to be able to access parent job/build from my pipeline, unfortunately it throws an error. {code:java} import org.jenkinsci.plugins.workflow.job.WorkflowJob import org.jenkinsci.plugins.workflow.job.WorkflowRun WorkflowJob ParentJob WorkflowRun ParentBuild pipeline { agent any stages { stage('Run') { steps { def cause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) if (cause == null) { currentBuild.result = 'ABORTED' error("Unknown parent build or current build was triggered by user directly.") } def parentJob = hudson.model.Hudson.instance.getItem(cause.upstreamProject) def parentBuild = parentJob.getBuildByNumber(cause.upstreamBuild) ParentJob = parentJob ParentBuild = parentBuild } } } } {code} |
Description |
Original:
I want to be able to access parent job/build from my pipeline, unfortunately it throws an error. {code:java} import org.jenkinsci.plugins.workflow.job.WorkflowJob import org.jenkinsci.plugins.workflow.job.WorkflowRun WorkflowJob ParentJob WorkflowRun ParentBuild pipeline { agent any stages { stage('Run') { steps { def cause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) if (cause == null) { currentBuild.result = 'ABORTED' error("Unknown parent build or current build was triggered by user directly.") } def parentJob = hudson.model.Hudson.instance.getItem(cause.upstreamProject) def parentBuild = parentJob.getBuildByNumber(cause.upstreamBuild) ParentJob = parentJob ParentBuild = parentBuild } } } } {code} |
New:
I want to be able to access parent job/build from my pipeline, unfortunately it throws an error. {code:java} import org.jenkinsci.plugins.workflow.job.WorkflowJob import org.jenkinsci.plugins.workflow.job.WorkflowRun WorkflowJob ParentJob WorkflowRun ParentBuild pipeline { agent any stages { stage('Run') { steps { def cause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) if (cause == null) { currentBuild.result = 'ABORTED' error("Unknown parent build or current build was triggered by user directly.") } def parentJob = hudson.model.Hudson.instance.getItem(cause.upstreamProject) def parentBuild = parentJob.getBuildByNumber(cause.upstreamBuild) ParentJob = parentJob ParentBuild = parentBuild } } } } {code} |
Description |
Original:
I want to be able to access parent job/build from my pipeline, unfortunately it throws an error. {code:java} import org.jenkinsci.plugins.workflow.job.WorkflowJob import org.jenkinsci.plugins.workflow.job.WorkflowRun WorkflowJob ParentJob WorkflowRun ParentBuild pipeline { agent any stages { stage('Run') { steps { def cause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) if (cause == null) { currentBuild.result = 'ABORTED' error("Unknown parent build or current build was triggered by user directly.") } def parentJob = hudson.model.Hudson.instance.getItem(cause.upstreamProject) def parentBuild = parentJob.getBuildByNumber(cause.upstreamBuild) ParentJob = parentJob ParentBuild = parentBuild } } } } {code} |
New:
I want to be able to access parent job/build from my pipeline, unfortunately it throws an error. {code:java} import org.jenkinsci.plugins.workflow.job.WorkflowJob import org.jenkinsci.plugins.workflow.job.WorkflowRun WorkflowJob ParentJob WorkflowRun ParentBuild pipeline { agent any stages { stage('Run') { steps { script { def cause = currentBuild.rawBuild.getCause(hudson.model.Cause$UpstreamCause) if (cause == null) { currentBuild.result = 'ABORTED' error("Unknown parent build or current build was triggered by user directly.") } def parentJob = hudson.model.Hudson.instance.getItem(cause.upstreamProject) def parentBuild = parentJob.getBuildByNumber(cause.upstreamBuild) ParentJob = parentJob ParentBuild = parentBuild } } } } }{code} |