# 环境变量
env 是定义整个Pipeline的环境变量,例如:"year"、"month"等 参照示例:[HelloWord](?id=创建 Helle World Pipeline)
示例脚本:主机[compile.example.com],进入[tmp]目录,输出定义变量参数值。
var pipeline={
node:"compile.example.com",
workspace:'/tmp',
env:{
year: "2020"
},
stages:{
test:{
env:{
month:"02"
},
steps:{
echo(){
$.sh('echo $year');
$.sh('echo $month');
}
}
}
}
};
输出结果:
[13:35]
开始执行
[echo13:35]
执行sh命令 echo $year
[echo13:35]
2020
[echo13:35]
执行sh命令 echo $month
[echo13:35]
02
[13:35]
Step【echo】执行完毕 0秒
[echo13:35]
stage【test】执行完毕 0秒
[echo13:35]