1
votes

I am using Jenkins Build Token Root plugin for triggering a project via script. As per the documentation, we can send an optional parameter Type while triggering a job like this:

buildByToken/buildWithParameters?job=RevolutionTest&token=TacoTuesday&Type=Mexican

I need to access this Type value inside the jenkins pipeline. How can I get that ?

So far I have tried to use

def causes = currentBuild.rawBuild.getCauses()
sh 'echo Causes: ${causes}'

But that raises exception

java.io.NotSerializableException: hudson.model.Cause$RemoteCause
1

1 Answers

0
votes

I had a similar problem, the next topic can help you:

NotSerializableException using Publish Over SSH in Jenkinsfile

Try something like it (put NonCPS function at end of your script):

sh 'echo Causes: ${getCauses()}'

@NonCPS
def getCauses() 
{
    return currentBuild.rawBuild.getCauses()
}