jenkinsfile

30 views
Skip to first unread message

Konstantin Raskoshnyi

unread,
Jul 20, 2018, 10:43:27 PM7/20/18
to jenkins...@googlegroups.com
Hello,
Is there anyway to return env variables from a job?
It works fine in pipeline, but with jenkinsfile scm pipeline I can't def variable inside steps.

This works fine inside pipeline:

      stage('pre') {
          build job: 'Test1'
      }
      stage('main') {
          def result = build job: 'Test', parameters: [string(name: 'VM', value: String.valueOf(VM))]
          println result.getBuildVariables()
     }


This doesn't:

pipeline {
  agent any
  stages {
    stage('pre') {
      steps {
        build job: 'Test1'
      }
    }
    stage('main') {
      steps {
        def result = build job: 'Test', parameters: [string(name: 'VM', value: String.valueOf(VM))]
        println result.getBuildVariables()
      }
    }
  }
}

Any help is appreciated.

Thanks

Stuart Rowe

unread,
Jul 23, 2018, 2:52:56 PM7/23/18
to Jenkins Users
Use the echo pipeline step instead of println:

pipeline {
  agent any
  stages
{
    stage
('pre') {
      steps
{
        build job
: 'Test1'
     
}
   
}
    stage
('main') {
      steps
{
       
def result = build job: 'Test', parameters: [string(name: 'VM', value: String.valueOf(VM))]

        echo result
.getBuildVariables().toString()
     
}
   
}
 
}
}
Reply all
Reply to author
Forward
0 new messages