main
ROOT /
pages /
job-variables.md
31 lines | ISO-8859-1 | 2 KB

Variables

Substitution Rule

Variable can be inserted into various fields of project build spec by surrounding with @. The list of available variables will be prompted when @ is typed. Below is some examples of variable substitutions (assume project name is foobar):

Original
SubstituedExplanation
ubuntu-@project_name@ubuntu-foobarcontents enclosed with @ is variable and will be substituted
ubuntu-@@project_name@@ubuntu-@project_name@@@ will be interpreted as literal @
ubuntu-@project_name@@OneDev will complain about invalid variable reference@project_name@ will be interpreted as a variable reference, and the last @ is singled out. The correct form should either be ubuntu-@project_name@@@, or ubuntu-@project_name@@someOtherVar@

Variable Reference

Variable
Explanation
project_namename of current project
project_pathpath of current project
job_namename of current job
refgit ref the job is running against. For instance:
  • if job runs against branch main, this value will be refs/heads/main
  • if job runs against tag v1, this value will be refs/tags/v1
branchgit branch this job is running against. This variable will be empty if job is not running against a branch
taggit tag this job is running against. This variable will be empty if job is not running against a tag
commit_hashgit commit hash this job is running against
build_numberserial number of generated build which can be used to reference the build
build_versionversion of generated build specified via step Set Build Version
pull_request_numberserial number of the pull request triggering the job as result of pull request open/update
param:<parameter name>value of specified job parameter spec
property:<property name>value of specified build spec property
script:builtin:<script name>run specified builtin groovy script and get the result
script:<script name>run specified custom groovy script and get the result
Please wait...
Page is in error, reload to recover