简体   繁体   中英

export command not working in Jenkins groovy

 export vara=$(grep '<Pattern>' $some_path/config/...../coreapplication_obips1/instanceconfig.xml | awk -F \> '{print $3}' | awk -F \< '{print $1}')

I am trying the above code in Jenkins pipeline using groovy script. It throws below error:

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310

How to execute shell script inside Jenkins groovy?

Refer the below to run shell and capture the output to a variable inside a Jenkins groovy file:-

vara = sh (script: 'shell script need to be executed', returnStdout: true)

You can try something like this:-

      steps {
         script {
                vara = sh (script: '''shell command''', returnStdout: true)
                echo " The value of variable id ${vara}"
                }
       }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM