简体   繁体   English

如何将管道参数传递给 shell 脚本

[英]How to to pass pipeline parameter to shell script

I have a groovy file which I need to use pipeline parameter in the shell script:我有一个 groovy 文件,我需要在 shell 脚本中使用管道参数:

def call() {
    echo "current build number: ${currentBuild.number}"
    def pipelineValue = "${currentBuild.number}"
    sh '''
        cd /jenkins/jenkins/workspace/Run_Distribution_Self_Service/
        mkdir -p builds/{pipelineValue }/libs/jfrog_distribution_shared_lib/resources/com/amdocs/python_distribution_util
'''

How can I get the pipelineValue in the shell script and use it?如何在 shell 脚本中获取 pipelineValue 并使用它?

Correct syntax:正确的语法:

mkdir -p builds/'''+pipelineValue+'''/libs/jfrog_distribution_shared_lib/resources/com/amdocs/python_distribution_util

the below link helped me: Pass groovy variable to shell script以下链接帮助了我: 将 groovy 变量传递给 shell 脚本

def call() {
echo "current build number: ${currentBuild.number}"
def pipelineValue = "${currentBuild.number}"
sh '''
    cd /jenkins/jenkins/workspace/Run_Distribution_Self_Service/
    mkdir -p builds/${pipelineValue}/libs/jfrog_distribution_shared_lib/resources/com/amdocs/python_distribution_util
'''

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Adonis JS 中将参数传递给 shell 脚本? - How to pass parameter to shell script in Adonis JS? 如何在Java程序中将参数传递给Shell脚本 - How to pass parameter to shell script in java program 如何在 Shell 脚本中传递命名参数 - How to pass Named Parameter in Shell Script 如何将参数从 shell 脚本传递到 SQL 脚本? - How to pass a parameter from shell script to SQL script? 如何将管道凭证参数作为环境变量传递给 python 脚本 - How to pass pipeline credential parameter to python script as env variable 将 jenkins 管道中设置的变量传递给 shell 脚本 - To pass variables set in jenkins pipeline to shell script 如何在shell脚本中将带有空格的参数传递给外部程序? - How to pass a parameter with space to an external program in a shell script? 如何将环境变量作为Dockerfile中的Shell脚本的参数传递? - How to pass Environment variables as a parameter of a shell script in Dockerfile? 如何在shell脚本中将表名作为参数传递给Bigquery命令行 - How to pass tablename as parameter to Bigquery command line in shell script 如何将参数传递给UNIX Shell脚本以在UNIX环境中运行作业 - How to Pass parameter to an unix shell script to run a job in an unix environment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM