当前位置: 首页> 财经> 股票 > Jenkins 内置变量 和变量作用域

Jenkins 内置变量 和变量作用域

时间:2025/7/9 15:31:53来源:https://blog.csdn.net/knight_zhou/article/details/139537708 浏览次数:0次

参考

##  参考
https://www.cnblogs.com/weiweifeng/p/8295724.html

常用的内置变量

## 内置环境变量地址
${YOUR_JENKINS_HOST}/jenkins/env-vars.html##  内置环境变量列表
https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables

变量作用域

Global environment

The environment block in a Jenkins pipeline can be defined at different levels, and the scope of the environment variables defined in each level varies:

  1. Global environment: Environment variables defined at the top-level environment block will be available to all stages and steps in the pipeline.
pipeline {agent anyenvironment {GLOBAL_VAR = "global value"}// ...
}

Stage environment

tage environment: Environment variables defined within a specific stage block will only be available to that stage and its steps.

pipeline {agent anystages {stage('Stage 1') {environment {STAGE_VAR = "stage 1 value"}steps {// GLOBAL_VAR and STAGE_VAR are available here}}stage('Stage 2') {environment {STAGE_VAR = "stage 2 value"}steps {// GLOBAL_VAR and STAGE_VAR (stage 2 value) are available here}}}
}

Step environment

  1. Step environment: Environment variables can also be defined within a specific step using the envInject step, which will only be available for that step.
pipeline {agent anystages {stage('Example') {steps {envInject {env:[STEP_VAR = "step value"]}// GLOBAL_VAR, STAGE_VAR, and STEP_VAR are available here}}}
}

关键字:Jenkins 内置变量 和变量作用域

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: