项目场景:
项目中用到jenkins做自动发布,其中一个环节需要用到powershell
问题描述
在powershell直接使用之前的bat中的变量使用方式,报错
powershell 'Expand-Archive -Path %param%\\test.zip -DestinationPath %param%'
提示变量无法替换
尝试了这种方法
powershell 'Expand-Archive -Path ${param}\\test.zip -DestinationPath ${param}'
仍然不行
查资料发现powershell在jenkins中能够使用变量的一种方法
powershell 'Expand-Archive -Path ${env:param}\\test.zip -DestinationPath ${env:param}'
附一篇介绍jenkins变量使用方法
https://www.jianshu.com/p/f88576649ce8