如何将Shell命令的输出分配给groovy脚本中的变量

时间:2018-07-24 11:10:29

标签: jenkins-pipeline

enter image description here我正在尝试运行以下常规代码,其中包括 -检查ansible是否已安装。如果未安装,则将其安装 代码:

stage(“检查Ansible安装”){         dir(“ $ {ScriptPath}”){             def data = sh'ssh ec2-user @ test“ yum -q已安装清单&& // dev / null && echo”已安装“ || echo”未安装“”             回显“'$ {数据}'”             如果'$ {data}'==“未安装” {               sh'ssh ec2-user @ test“ sudo yum install epel-release”'               sh'ssh ec2-user @ test“ yum install ansible”“              }             其他{                sh'ssh ec2-user @ test“ ansible --version”'                }             sh'ssh ec2-user @ test“ cat / etc / ansible / hosts”'             // sh'ssh ec2-user @ test“ mkdir ansible”'             sh'scp -r * .yaml ec2-user @ test:/ home / ec2-user /'

错误: [testpipelinejobsom]运行shell脚本 + ssh ec2-user @ jump'yum -q已安装清单ansible&> / dev / null && echo已安装||回声未安装 未安装 [管道]回声 '空值' [管道] sh [testpipelinejobsom]运行shell脚本 + ssh ec2-user @ jump'ansible --version'

0 个答案:

没有答案