Templating .ci.yml
Environment Variables
In addition to Jenkins build variables, DotCi provides the following global variables:
DOTCI_BRANCH
- current branchDOTCI
- always trueCI
- always trueDOTCI_SHA
- current sha being builtGIT_URL
- git urlDOTCI_PUSHER
- github username whose git push triggred this buildDOTCI_PULL_REQUEST
- pull request number being builtDOTCI_PULL_REQUEST_SOURCE_BRANCH
- the pull request branchDOTCI_PULL_REQUEST_TARGET_BRANCH
- the branch the pull request is targeting
Groovy templating
.ci.yml
acts as a groovy
template which is run
through a groovy preprocessor before build starts.
Examples
Send extra notification to yourself for a build you started:
notifications:
<% if (DOTCI_PUSHER == 'joe') { %>
- sms: 1234344453
<% } %>
Run certain commands after tests when DOTCI_BRANCH
is production
:
build:
run: rake spec
#run integration tests only on production branch
<% if (DOTCI_BRANCH == 'production') { %>
after: rake integration
<%} %>
Notify hipchat room DevOps
when DOTCI_BRANCH
is master
:
notifications:
<% if (DOTCI_BRANCH == 'master') { %>
- hipchat: 'DevOps'
<%}%>
Pass DOTCI_BRANCH
as a parameter to webhook:
plugins:
- webhook:
url: http://example.com/hook
params:
branch: ${DOTCI_BRANCH}
Artifact files when DOTCI_BRANCH
is master
:
build:
<% if( DOTCI_BRANCH != 'master') {%>
- artifacts: 'packages/**/*.war'
<%}%>