打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Jenkins内置环境变量的使用
Jenkins内置环境变量的使用
Posted on 2015-09-22 15:17Glen He 阅读(239) 评论(0)编辑
一、查看Jenkins有哪些环境变量
1、新建任意一个job
2、增加构建步骤:Execute shell 或 Execute Windows batch command
3、点击输入框下方的“可用环境变量”
4、可以看到有如下变量供使用:
变量名解释
BUILD_NUMBERThe current build number, such as "153"
BUILD_IDThe 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_NAMEThe display name of the current build, which is something like "#153" by default.
JOB_NAMEName 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_TAGString of "jenkins-${JOB_NAME}-${BUILD_NUMBER}". Convenient to put into a resource file, a jar file, etc for easier identification.
EXECUTOR_NUMBERThe 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_NAMEName of the slave if the build is on a slave, or "master" if run on master
NODE_LABELSWhitespace-separated list of labels that the node is assigned.
WORKSPACEThe absolute path of the directory assigned to the build as a workspace.
JENKINS_HOMEThe absolute path of the directory assigned on the master node for Jenkins to store data.
JENKINS_URLFull URL of Jenkins, like http://server:port/jenkins/ (note: only available if Jenkins URL set in system configuration)
BUILD_URLFull URL of this build, like http://server:port/jenkins/job/foo/15/ (Jenkins URL must be set)
SVN_REVISIONSubversion revision number that's currently checked out to the workspace, such as "12345"
SVN_URLSubversion URL that's currently checked out to the workspace.
JOB_URLFull 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>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
一步一步构建iOS持续集成:Jenkins+GitLab+蒲公英+FTP
pipeline常用插件用法
java – 使用Jenkins内部版本号安装/部署Maven
使用jenkins实现持续集成
如何用Jenkins触发另一个Jenkins---Global build solution
手把手教你使用 Jenkins+Docker 实现持续集成
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服