Jenkins内置环境变量

一、查看Jenkins有哪些环境变量

1、新建任意一个job

2、增加构建步骤:Execute shell 或 Execute Windows batch command

3、点击输入框下方的“可用环境变量”

4、可以看到有如下变量供使用:

变量名 解释
BUILD_NUMBER The current build number, such as "153"
BUILD_ID The current build ID, identical to BUILD_NUMBER for builds created in 1.597+, but a YYYY-MM-DD_hh-mm-ss timestamp for older builds
BUILD_DISPLAY_NAME The display name of the current build, which is something like "#153" by default.
JOB_NAME Name of the project of this build, such as "foo" or "foo/bar". (To strip off folder paths from a Bourne shell script, try: ${JOB_NAME##*/})
BUILD_TAG String of "jenkins-${JOB_NAME}-${BUILD_NUMBER}". Convenient to put into a resource file, a jar file, etc for easier identification.
EXECUTOR_NUMBER The unique number that identifies the current executor (among executors of the same machine) that’s carrying out this build. This is the number you see in the "build executor status", except that the number starts from 0, not 1.
NODE_NAME Name of the slave if the build is on a slave, or "master" if run on master
NODE_LABELS Whitespace-separated list of labels that the node is assigned.
WORKSPACE The absolute path of the directory assigned to the build as a workspace.
JENKINS_HOME The absolute path of the directory assigned on the master node for Jenkins to store data.
JENKINS_URL Full URL of Jenkins, like http://server:port/jenkins/ (note: only available if Jenkins URL set in system configuration)
BUILD_URL Full URL of this build, like http://server:port/jenkins/job/foo/15/ (Jenkins URL must be set)
SVN_REVISION Subversion revision number that‘s currently checked out to the workspace, such as "12345"
SVN_URL Subversion URL that‘s currently checked out to the workspace.
JOB_URL Full URL of this job, like http://server:port/jenkins/job/foo/ (Jenkins URL must be set)

二、使用Jenkins的内置变量

1、在Execute shell 或 Execute Windows batch command文本框中使用,使用方法:%变量名%,如下图

  

2、结合Ant,在build.xml文件中使用:

  1、添加如下第4行代码:<property environment="env"/>

  2、使用方法:${env.WORKSPACE}

 1 <?xml version="1.0" encoding="UTF-8"?>
 2
 3 <project name="ant-test" default="run" basedir=".">
 4     <property environment="env"/>
 5
 6     <target name="clean">
 7         <mkdir dir="${env.WORKSPACE}/results/${env.BUILD_ID}" />
 8     </target>
 9
10 </project>
时间: 2024-08-25 04:09:28

Jenkins内置环境变量的相关文章

MySQL-配置环境变量及修改密码(附-mysql安装教程)

MySQL-配置环境变量和修改密码 一. 闪退问题 1.1.没有配置环境变量 例如下图: 1.2.  不用输入密码直接进入 直接在输入密码步骤回车. 1.3.  没有启动mysql服务 二. 配置环境变量 2.1.  配置环境的好处 a)没有配置环境的情况下:输入mysql -u root -p  错误 输入命令 cd C:\Program Files\MySQL\MySQL Server 5.7\bin(我mysql的路径,具体路径看你本人安装路径) 跳转到启动路径下,启动mySql b)配置

Flask内置URL变量转换器

Flask内置URL变量转换器: 转换器通过特定的规则执行,"<转换器: 变量名>".<int: year>把year的值转换为证书,因此我们可以在视图函数中直接对year变量进行数学计算: @app.route('/goback/<int:year>' def go_back(year):     return '<p>Welcom to %s ! </p>' %(2019-year) if __name__ == '__m

jenkins 内置变量

1. 邮件配置变量 ${GIT_BRANCH} build 的 Git 分支 ${FILE,path="PATH"} 包括指定文件(路径)的含量相对于工作空间根目录. path文件路径,注意:是工作区目录的相对路径. ${BUILD_NUMBER} 显示当前构建的编号. ${JOB_DESCRIPTION} 显示项目描述. ${SVN_REVISION} 显示svn版本号.还支持Subversion插件出口的SVN_REVISION_n版本. ${CAUSE} 显示谁.通过什么渠道触发

[Perl] 内置特殊变量

一.正则表达式特殊变量:1.$n  :包含上次模式匹配的第n个子串2.$& :前一次成功模式匹配的字符串3.$`  :前次匹配成功的子串之前的内容4.$' :前次匹配成功的子串之后的内容5.$+ :前一次使用括号的模式匹配的字符串. 二.文件句柄特殊变量:1.$| :如果设置为零,在每次调用函数write或print后,自动调用函数fflush,将所写内容写回文件2.$% :当前输出页号3.$= :当前每页长度4.$- :当前页剩余的行数5.$~ :当前报表输出格式的名称.默认值是文件句柄名.6

Perl内置特殊变量

一.正则表达式特殊变量: 1.$n  :包含上次模式匹配的第n个子串 2.$& :前一次成功模式匹配的字符串 3.$`  :前次匹配成功的子串之前的内容 4.$' :前次匹配成功的子串之后的内容 5.$+ :前一次使用括号的模式匹配的字符串. 二.文件句柄特殊变量: 1.$| :如果设置为零,在每次调用函数write或print后,自动调用函数fflush,将所写内容写回文件 2.$% :当前输出页号 3.$= :当前每页长度 4.$- :当前页剩余的行数 5.$~ :当前报表输出格式的名称.默

jenkins+gradle+android环境变量配置

1.jenkins添加gradle插件 2.环境变量配置[mac mini] 可以自己写profile文件,也可以放到/etc/.profile里面. JDK: export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0.jdk/Contents/Home Android[adt-bundle]: export ANDROID_HOME=/Users/git/android/adt-bundle-mac-x86_64-20130514/

nginx内置常用变量

HTTP核心模块支持一些内置变量,变量名与apache里的对应.比如 $http_user_agent,$http_cookie等表示HTTP请求信息的变量. 更多变量: $args, 请求中的参数; $content_length, HTTP请求信息里的”Content-Length”; $content_type, 请求信息里的”Content-Type”; $document_root, 针对当前请求的根路径设置值; $document_uri, 与$uri相同; $host, 请求信息中

mysql全文索引____内置分词变量

上一节,我们发现搜索'a',但是发现'aa','aaa','aaaa'搜索不出来.为什么呢? 这就涉及到mysql的一个内置变量ft_boolean_syntax. ft_boolean_syntax Variable_name    Value ft_boolean_syntax    + -><()~*:""&|(其中有一个空格) 该变量的意思,表示需要被全文索引的字段通过以上这些变量进行分词切分. 譬如有一段字符串"a,b,c,ab",如果

Unity 内置Shader变量、辅助函数等

一:标准库里的常用.cginc文件 HLSLSupport.cginc - (automatically included) Helper macros and definitions for cross-platform shader compilation. HLSLSupport.cginc :(自动包含)跨平台着色器编译帮助宏和定义 UnityCG.cginc - commonly used global variables and helper functions. UnityCG.c