ParentJob and ParentBuild as properties

10 views
Skip to first unread message

Jakub Pawlinski

unread,
Jul 11, 2017, 5:42:30 AM7/11/17
to Jenkins Users
Hi, 

In my declarative pipeline I'm using some data from parent job, till now I was processing those in single script clause and setting :

String ParentJobName = ""
String ParentBuildNumber = ""

pipeline {
stages {
stage ('Read Parameters') {
steps {
script {
def parentJob = GetParentJob(params.VERBOSE)
ParentJobName = parentJob.getName()

def parentBuild = GetParentBuild(parentJob, params.VERBOSE)
ParentBuildNumber = parentBuild.getNumber()
...

this was working fine, and both ParentJobName and ParentBuildNumer were populated fine, 

as I now wanted to do more than just getting single string I tried to declare

import org.jenkinsci.plugins.workflow.job.WorkflowJob
import org.jenkinsci.plugins.workflow.job.WorkflowRun

WorkflowJob ParentJob
WorkflowRun ParentBuild

outside of pipeline (like Strings previously)

but this ends up with java.io.NotSerializableException: org.jenkinsci.plugins.workflow.job.WorkflowJob exception

wonder if there is a way to achieve it, so I want have to evaluate those every time I want to use them.

thanks
Jakub
Reply all
Reply to author
Forward
0 new messages