导出命令在Jenkins Groovy中不起作用

时间:2019-03-11 08:20:05

标签: shell jenkins groovy

import pandas as pd
from scipy import interpolate
import pylab as pl
import numpy as np

df = pd.read_csv('aa.txt', delim_whitespace=True)
xnew=np.linspace(df["time"],len(df["data"]),60)
f=interpolate.interp1d(df["time"],df["data"],kind="cubic")

ynew=f(xnew)
pl.plot(xnew,ynew,label="cubic", marker='.' )
pl.show()

我正在使用groovy脚本在Jenkins管道中尝试上述代码。它抛出以下错误:

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

如何在Jenkins Groovy中执行shell脚本?

1 个答案:

答案 0 :(得分:0)

请参阅以下内容运行shell,并将输出捕获到Jenkins groovy文件中的变量中:-

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

您可以尝试以下操作:-

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