0

So I have a jenkins job that checkout a svn repo like this remote: "svn://xyz-repo/svn/xyzclientjs/$BRANCH_NAME"]],

I pass this $BRANCH_NAME through a Jenkinsfile that is present in this svn repo.

Now Inside Jenkinsfile I am doing this -

node 'xyz-169' { 

  checkout scm
  def BRANCH_NAME = sh "svn info | grep -Po 'Relative URL: \\^/\\K.*'"
  def BRANCH_REV = sh "svn info --show-item revision"

    stage('Build A') {
         build job: 'xyzclientjs-webui-test', propagate: true, parameters:
            [
              [$class: 'StringParameterValue', name: 'BRANCH_NAME', value: $env.BRANCH_NAME],
              [$class: 'StringParameterValue', name: 'BRANCH_REV', value: $env.BRANCH_REV],
            ]

But when I run the job on jenkins I get following error

Error while checking out xyzclientjs branch from SVN
10:26:05  [Pipeline] error
10:26:05  [Pipeline] }
10:26:05  [Pipeline] // stage
10:26:05  [Pipeline] }
10:26:05  [Pipeline] // node
10:26:05  [Pipeline] End of Pipeline
10:26:05  java.lang.ClassCastException: org.jenkinsci.plugins.workflow.steps.ErrorStep.message expects class java.lang.String but received class groovy.lang.MissingPropertyException

Is there any way to do this. Please help any suggestions would be highly appriciated.

samkraken
  • 31
  • 1
  • 8

1 Answers1

0

You should have a look here for an example to correctly fetch the output of a sh step:

How do I get the output of a shell command executed using into a variable from Jenkinsfile (groovy)?

For example (not tested due to lack of SVN):

def BRANCH_NAME = sh (
  script: "svn info | grep -Po 'Relative URL: \\^/\\K.*'",
  returnStdout: true
).trim()
Franco
  • 193
  • 1
  • 9