Quantcast
Viewing all articles
Browse latest Browse all 3

How to define variable in Jenkins declarative pipeline?

I defined variable in declarative Jenkins pipeline script but having issues with simple variable declaration.

Here is my script:

pipeline {    agent none    stages {        stage("first") {            def foo = "foo" // fails with "WorkflowScript: 5: Expected a step @ line 5, column 13."            sh "echo ${foo}"        }    }}

but it's shows error:

org.codehaus.groovy.control.MultipleCompilationErrorsException:startup failed:WorkflowScript: 5: Expected a step @ line 5, column 13.    def foo = "foo"    ^

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>