Buddy parameters
Buddy parameters are now deprecated for all new accounts in favor of the environment variables. The parameters remain available for accounts registered prior to September 21, 2018, although we do recommend to switch to ENV VARs as soon as possible.
A note before you start:
- the
url
attribute refers to the API - the
html_url
attribute refers to the website [index]
is the number of subsequent action executions counted from 0 (there can be more than one)- Buddy uses Velocity Template Engine syntax. The model of execution is the same that we use in our external API. It is described in detail in the pipelines/executions resource of the API documentation.
List of Buddy parameters
You can use the following parameters in SSH scripts, web hooks and notifications:
${workspace.url}
${workspace.html_url}
${workspace.id}
${workspace.name}
${workspace.domain}
${invoker.url}
${invoker.html_url}
${invoker.id}
${invoker.name}
${invoker.title}
${invoker.avatar_url}
${invoker.email}
${project.url}
${project.html_url}
${project.name}
${project.display_name}
${project.repository_type}
${project.status}
${execution.url}
${execution.html_url}
${execution.id}
${execution.start_date}
${execution.finish_date}
${execution.mode}
${execution.refresh}
${execution.status}
${execution.comment}
${execution.branch.url}
${execution.branch.html_url}
${execution.branch.name}
${execution.branch.default}
${execution.from_revision.url}
${execution.from_revision.html_url}
${execution.from_revision.revision}
${execution.from_revision.short_revision}
${execution.from_revision.message}
${execution.from_revision.tags}
${execution.from_revision.author.email}
${execution.from_revision.committer.id}
${execution.from_revision.committer.url}
${execution.from_revision.committer.html_url}
${execution.from_revision.committer.name}
${execution.from_revision.committer.avatar_url}
${execution.from_revision.committer.email}
${execution.to_revision.url}
${execution.to_revision.html_url}
${execution.to_revision.revision}
${execution.to_revision.short_revision}
${execution.to_revision.message}
${execution.to_revision.tags}
${execution.to_revision.author.email}
${execution.to_revision.committer.id}
${execution.to_revision.committer.url}
${execution.to_revision.committer.html_url}
${execution.to_revision.committer.name}
${execution.to_revision.committer.avatar_url}
${execution.to_revision.committer.email}
${execution.changelog.added}
${execution.changelog.modified}
${execution.changelog.deleted}
${execution.changelog.commits}
${execution.changelog.commits[index].url}
${execution.changelog.commits[index].html_url}
${execution.changelog.commits[index].revision}
${execution.changelog.commits[index].author_date}
${execution.changelog.commits[index].commit_date}
${execution.changelog.commits[index].message}
${execution.changelog.commits[index].committer.email}
${execution.changelog.commits[index].author.email}
${execution.changelog.commits[index].content_url}
${execution.creator.id}
${execution.creator.url}
${execution.creator.html_url}
${execution.creator.name}
${execution.creator.avatar_url}
${execution.creator.title}
${execution.creator.email}
${execution.pipeline.html_url}
${execution.pipeline.url}
${execution.pipeline.id}
${execution.pipeline.name}
${execution.pipeline.ref_name}
${execution.pipeline.trigger_mode}
${execution.pipeline.last_execution_status}
${execution.pipeline.last_execution_revision}
${execution.pipeline.target_site_url}
${execution.pipeline.always_from_scratch}
${execution.action_executions[index].status}
${execution.action_executions[index].progress}
${execution.action_executions[index].log_url}
${execution.action_executions[index].log}
${execution.action_executions[index].action.url}
${execution.action_executions[index].action.html_url}
${execution.action_executions[index].action.id}
${execution.action_executions[index].action.name}
${execution.action_executions[index].action.type}
${execution.action_executions[index].action.trigger_time}
${execution.action_executions[index].action.last_execution_status}
${execution.action_executions[index].action.run_only_on_first_failure}
Please note that some parameters may not be available in selected fields. For example, when running a deploy from scratch ${execution.to_revision}
is inactive and will not be replaced with a value.
You can force to replace the inactive fields with an empty string by adding an exclamation mark before the variable:
$!{execution.to_revision}
Displaying multi-line parameters with velocity syntax
You can use the velocity syntax to display multi-line parameters, for example in execution logs:
#set($buildAction=$execution.action_executions[0]) ## First action
Link to full log: ${buildAction.log_url}
Lines:
#foreach( $line in $buildAction.log)
Line ${velocityCount}: ${line}
#end
Displaying date with Buddy parameters
You can show the date in one of two ways:
$DateUtils.newDateTime('Europe/Warsaw').toDateTimeISO() or
Date 1: $DateUtils.newDateTime('Europe/Warsaw').toString('YYY dd MMM hh:mm')
- Click here for the list of time zones that you can provide.
- Click here for the list of supported time formats.
Displaying date in a custom format
If you want to show the date in your own format, you can use:
${DateUtils.fromString(${execution.start_date}).toString('YYY MM dd')}
Calculating time
If you want to calculate, for example, execution time and use it in the email notification content, you can do:
#set ($total = $DateUtils.newDateTime('Etc/GMT').getMillis() -
$DateUtils.fromString(${execution.start_date}).getMillis() )
Total: $total millis
Fetching logs from failed action
If you want to get logs only from action that caused execution failure, you can do:
#foreach( $action in $execution.action_executions)
#if( $action.status == "FAILED" )
#foreach( $line in $action.log)
${line}
#end
#end
#end
Fetching variables from the execution object
You can fetch more variables from the execution
object using:
${execution.action_executions.get(0).to_revision}
Here’s an example execution
object:JSON
{
"workspace": {
"url": "https://app.buddy.works/workspaces/buddy-works",
"html_url": "https://app.buddy.works/buddy-works",
"id": 1,
"name": "Buddy",
"domain": "buddy.works"
},
"invoker": {
"id": 1,
"avatar_url": "https://app.buddy.works/buddy-works/image-server/user/0/0/0/0/0/0/1/d643744fbe5ebf2906a4d075a5b97110/w/30/30/CHUCK.png?ts=1432213093596",
"email": "mike@buddy.works",
"name": "Mike Benson"
},
"project": {
"url": "https://app.buddy.works/projects/roundkick-v2",
"html_url": "https://app.buddy.works/beta/roundkick-v2",
"name": "roundkick-v2",
"display_name": "Roundkick v2.0"
},
"current_date": "2015-08-17T10:45:20.044Z",
"execution": {
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2/executions/3",
"html_url": "https://app.buddy.works/buddy/company-website/pipelines/pipeline/2/execution/56fa37f499f1e10c105fb388",
"id": 3,
"start_date": "2016-03-29T08:08:20.205Z",
"finish_date": null,
"mode": "MANUAL",
"refresh": false,
"status": "INPROGRESS",
"comment": "hotfix",
"branch": {
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/repository/branches/master",
"html_url": "https://app.buddy.works/buddy/company-website/repository/branch/master",
"name": "master",
"default": true
},
"from_revision": {
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/repository/commits/506a3963507943d6908154f4bc9646e829128a08",
"html_url": "https://app.buddy.works/buddy/company-website/repository/commit/506a3963507943d6908154f4bc9646e829128a08",
"revision": "506a3963507943d6908154f4bc9646e829128a08",
"message": "init repo\n"
},
"to_revision": {
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/repository/commits/506a3963507943d6908154f4bc9646e829128a08",
"html_url": "https://app.buddy.works/buddy/company-website/repository/commit/506a3963507943d6908154f4bc9646e829128a08",
"revision": "506a3963507943d6908154f4bc9646e829128a08",
"message": "init repo\n"
}
},
"creator": {
"url": "https://api.buddy.works/workspaces/buddy/member/1",
"html_url": "https://app.buddy.works/buddy/profile/1",
"id": 1,
"name": "Mike Benson",
"avatar_url": "https://app.buddy.works/image-server/user/0/0/0/0/0/0/1/d643744fbe5ebf2906a4d075a5b97110/w/32/32/AVATAR.png",
"title": "Creative director",
"email": "mike@buddy.works"
},
"pipeline": {
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2",
"html_url": "https://app.buddy.works/buddy/company-website/pipelines/pipeline/2",
"id": 2,
"name": "dev",
"on": "CLICK",
"refs": [
"refs/heads/master"
],
"last_execution_status": "INPROGRESS",
"last_execution_revision": "506a3963507943d6908154f4bc9646e829128a08"
},
"action_executions": [
{
"status": "INPROGRESS",
"progress": 0.0,
"action": {
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2/actions/5",
"html_url": "https://app.buddy.works/buddy/company-website/pipelines/action/5/edit",
"id": 5,
"name": "Upload files to dev",
"type": "FTP",
"trigger_time": "ON_EVERY_EXECUTION",
"last_execution_status": "INPROGRESS",
"run_only_on_first_failure": false
}
}
]
}
Using non-Buddy variables in builds and SSH scripts
If you are using variables which are not on the list of Buddy parameters, then your script may not be executed properly. In order to prevent that you need to escape such parameter using #[[param]]#
.
For example, instead of
filename="myfile.ext"
echo ${filename##*.}
enter
filename="myfile.ext"
echo #[[${filename##*.}]]#
Last modified on September 8, 2022