当前位置:网站首页>Jenkins - built in variable access
Jenkins - built in variable access
2022-06-28 02:13:00 【wumingxiaoyao】
introduction
I have been puzzled by Jenkins An environment variable of CAUSE, Call... In the mail plug-in ${CAUSE} It is feasible. , But elsewhere ( perform Shell or Python Script time ), Really can only get None value . original Jenkins Built in variables are divided into two categories , A configuration variable that is only used for mail configuration , One is the global environment variable , Let's take a look at these variables .
Summary :
- Jenkins Built in variable view
- Jenkins Built in variable access
- Jenkins Built in mail configuration variables
- Jenkins Built in environment variables
Jenkins Built in variable view
- Jenkins URL + /env-vars.html/
for example : http://localhost:8080/env-vars.html/
- Jenkins URL + /pipeline-syntax/globals
for example : http://localhost:8080/pipeline-syntax/globals
Jenkins Built in variable access
List some common environment variables , Be careful CAUSE Variables are used for mail configuration , Used elsewhere is None value .
Jenkins Email configuration :
Just apply it ${CAUSE} Variable , The details of the email plug-in will be introduced next time .
Mail output :
Shell command
adopt ${Env_Variable_Name} or %{Env_Variable_Name}% visit
Shell Script :
echo "JENKINS_HOME: ${JENKINS_HOME}"
echo "JENKINS_URL: ${JENKINS_URL}"
echo "BUILD_URL: ${BUILD_URL}"
echo "BUILD_NUMBER: ${BUILD_NUMBER}"
echo "JOB_URL: ${JOB_URL}"
echo "JOB_NAME: ${JOB_NAME}"
echo "WORKSPACE: ${WORKSPACE}"
echo "CAUSE: ${CAUSE}"
Jenkins To configure :
Jenkins Output :
Python Script
import os
print("JENKINS_HOME: {} ".format(os.getenv('JENKINS_HOME')))
print("JENKINS_URL: {} ".format(os.getenv('JENKINS_URL')))
print("BUILD_URL: {} ".format(os.getenv('BUILD_URL')))
print("BUILD_NUMBER: {} ".format(os.getenv('BUILD_NUMBER')))
print("JOB_URL: {} ".format(os.getenv('JOB_URL')))
print("JOB_NAME: {} ".format(os.getenv('JOB_NAME')))
print("WORKSPACE: {} ".format(os.getenv('WORKSPACE')))
print("CAUSE: {} ".format(os.getenv('CAUSE')))
Jenkins To configure :
Jenkins Output :
Jenkins Built in mail configuration variables
| Variable | explain |
|---|---|
| ${GIT_BRANCH} | Git Branch |
| ${FILE,path=“xxx”} | xxx For the specified file , The contents of the file can be displayed in the mail . Be careful :xxx Is the relative path to the workspace directory , It's not an absolute path . |
| ${JOB_DESCRIPTION} | Show item description . |
| ${BUILD_NUMBER} | Displays the number of the current build . |
| ${SVN_REVISION} | Show svn Version number . And support Subversion Plug in exit SVN_REVISION_n edition . |
| ${CAUSE} | Show who 、 What channels trigger this build . |
| ${CHANGES } | Show changes since last build . |
| ${BUILD_ID} | Displays the generated by the current build ID. |
| ${PROJECT_NAME} | Displays the full name of the item . |
| ${PROJECT_DISPLAY_NAME} | Displays the display name of the item . |
| SCRIPT | Generate custom message content from a script . Custom scripts should be placed in “JENKINS_HOME/email-templates”. When using custom scripts, the default search is $JENKINS_HOME/email-templatesdirectory Catalog . Other directories will not be searched . |
| ${JENKINS_URL} | Show Jenkins Server's url Address ( It can be changed on the system configuration page ). |
| ${BUILD_LOG_MULTILINE_REGEX} | Match by regular expression and display the build log . |
| ${BUILD_LOG} | Show the final build log . |
| ${PROJECT_URL} | Displays the of the item URL Address . |
| ${BUILD_STATUS} | Displays the status of the current build ( Failure 、 Success, etc ). |
| ${BUILD_URL} | Displays the currently built URL Address . |
| ${CHANGES_SINCE_LAST_SUCCESS} | Show changes since the last successful build . |
| ${CHANGES_SINCE_LAST_UNSTABLE} | Show changes since the last unstable or successful build . |
| ${ENV} | Displays an environment variable . |
| ${FAILED_TESTS} | If there are failed tests , Show these failed unit test information . |
| ${PROJECT_URL} | Displays the of the item URL . |
| JELLYSCRIPT | From a Jelly Custom message content in script template . There are two templates to configure :HTML and TEXT. You can JENKINS_HOME/email-templates Replace it under custom . When using auto - semantic templates ,”template” The name of the parameter does not contain “.jelly”. |
| ${TEST_COUNTS} | Displays the number of tests . |
Jenkins Built in environment variables
| Variable | explain |
|---|---|
| BRANCH_NAME | For multi branch projects , This will be set to the name of the branch being built , for example , If you want to master Not from feature branch deployment to production . |
| CHANGE_ID | For a multi branch project corresponding to a change request , This will be set to change ID, For example, pull request number . |
| CHANGE_URL | For a multi branch project corresponding to a change request , This will be set to change URL. |
| CHANGE_TITLE | For a multi branch project corresponding to a change request , This will be set to change the title . |
| CHANGE_AUTHOR | For a multi branch project corresponding to a change request , This will be set to the user name of the author of the proposed change . |
| CHANGE_AUTHOR_DISPLAY_NAME | For a multi branch project corresponding to a change request , This will be set to the author's name . |
| CHANGE_AUTHOR_EMAIL | For a multi branch project corresponding to a change request , This will be set as the author's e-mail address . |
| CHANGE_TARGET | For a multi branch project corresponding to a change request , This will be set to the target or base branch where changes can be merged . |
| BUILD_NUMBER | The current number , Such as “153” |
| BUILD_ID | current version ID, And BUILD_NUMBER identical , Used in 1.597+ Zhongchuang Construction of building , But older versions YYYY-MM-DD_hh-mm-ss Time stamp |
| BUILD_DISPLAY_NAME | Display name of the current version , The default is “#153”. |
| JOB_NAME | The name of this build project , Such as “foo” or “foo / bar”. |
| JOB_BASE_NAME | The name of this build project will split the folder path , for example “bar / foo” Of “foo”. |
| BUILD_TAG | “jenkins- JOBNAME−{BUILD_NUMBER} ” String .JOB_NAME All forward slashes in (/) Will use dashes ( - ) Replace . Easy to put in resource files ,jar Documents, etc. , In order to identify . |
| EXECUTOR_NUMBER | Identify the current program executing this build ( In the execution program of the same computer ) The unique number of . This is you in “ Build performer status ” The numbers seen in , But the numbers start from 0 Start , instead of 1. |
| NODE_NAME | The name of the agent , If the build is a proxy , perhaps “ Lord ”, If running on the host |
| NODE_LABELS | Space delimited node assigned label list . |
| WORKSPACE | The absolute path assigned to the directory to build as the workspace . |
| JENKINS_HOME | Jenkins The absolute path of the directory allocated on the master node stores data . |
| JENKINS_URL | complete Jenkins website , for example http:// server:port / jenkins /( Be careful : Only when... Is set in the system configuration Jenkins URL) |
| BUILD_URL | The complete of this build URL, Such as http:// server:port / jenkins / job / foo / 15 /(Jenkins URL You have to set ) |
| JOB_URL | The complete of this job URL, Such as http:// server:port / jenkins / job / foo /( You have to set Jenkins URL) |
| SVN_REVISION | Subversion Version number , Currently checked out to the workspace , Such as “12345” |
| SVN_URL | Currently checked out to the workspace Subversion URL. |
边栏推荐
- Intranet penetration with FRP
- Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
- [embedded foundation] memory (cache, ram, ROM, flash)
- Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa
- Overview of drug discovery-01 overview of drug discovery
- 嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)
- Jenkins - Pipeline 概念及创建方式
- Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)
- Using redis bitmap to realize personnel online monitoring
- Fundamentals of scala (3): operators and process control
猜你喜欢

ShardingSphere-proxy-5.0.0建立mysql读写分离的连接(六)

评价——秩和比综合评价

Solve storage problems? WMS warehouse management system solution

【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩

fiddle如何使用代理

Cesium 多边形(polygon)extrudedHeight 和 height 的区别

The interviewer asked: can you simulate the new operator of JS

嵌入式必学!硬件资源接口详解——基于ARM AM335X开发板 (下)

要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程

Appium自动化测试基础— 补充:App的包名(appPackage)和启动名(appActivity)
随机推荐
Is it safe to open an online futures account?
网络爬虫是什么
引用层reboot后的大体流程
The research group of Xuyong and duanwenhui of Tsinghua University has developed an efficient and accurate first principles electronic structure deep learning method and program
mysql面试百题集
Jenkins - Groovy Postbuild 插件丰富 Build History 信息
基于AM335X开发板 ARM Cortex-A8——Acontis EtherCAT主站开发案例
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
Appium automation test foundation - Supplement: app package name and appactivity
Intranet penetration with FRP
Evaluation - grey correlation analysis
[Yocto RM] 4 - Source Directory Structure
[Yocto RM] 2 - Yocto Project Terms
Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection
[Yocto RM]9 - QA Error and Warning Messages
【sylixos】i2c设备驱动创建和使用
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
Drug interaction prediction based on learning size adaptive molecular substructure
Overview of drug discovery-01 overview of drug discovery
Ten MySQL locks, one article will give you full analysis