Python build tools for Atlassian Bamboo
There is a set of tools used in Rutube for release management.
All bamboo SVN tools require SVN commit messages to start with JIRA task key,
PROJ-123 some feature implemented.
Project directory stucture in SVN is following: /trunk # trunk location /branches/stable # stable branches location, named like 1.x or 1.2.x /tags/release # tags location for JIRA version 1.2.3, and /tags/release/1.2.3/ # builds dir for version 1.2.3
Project root may be not only the repo root, but any other path, if there are several project in one SVN repo.
Used to correctly create stable from trunk or released tag.
svn-create-stable -t http://svn.example.org/project PROJ-9 1.1.x
PROJ-9 is JIRA task key for "Integration task" used in commit message for stable creation, 1.1.x - stable name. Rules for stable creation are following:
- Major stables are created from trunk
- Minor stable 1.1.x is created from last build of 1.1.0 tag.
- -b you can choose branch to copy from
- -i interactive mode, asks before commits
- -c config file (see below)
- -t SVN project root url
Used to search JIRA task keys mentioned in commit messages.
svn-log-tasks -b http://svn.example.org/project PROJ
PROJ is JIRA project key.
- -b branch to look for tasks
- -r revision to start from (default is 100 revisions before HEAD)
- -c config file (see below)
collected:
PROJ-5,PROJ-6,PROJ-8
PROJ-5: 5,6,7,9,14,15
PROJ-6: 1,2,3,4,8,10,13
PROJ-8: 11,12
First line is a list of found JIRA tasks, last lines are lists of revisions sorted by JIRA tasks.
Tool to collect and merge to stable all commits by JIRA task key.
svn-merge-tasks -t http://svn.rutube.ru/project -i PROJ-9 PROJ-6 PROJ-5
PROJ-9 is "Integration task" used in commit message, other args are tasks to merge.
stable branch must checked out to current directory.
- -i interactive mode, asks before commits
- -c config file (see below)
- -t SVN project root url
- -b branch to merge from (default is trunk)
Creates tag from stable
svn-release -t http://svn.rutube.ru/project -i PROJ-9 1.2.3
PROJ-9 is "Integration task" used in commit message, 1.2.3 is version to build.
- -i interactive mode, asks before commits
- -c config file (see below)
- -t SVN project root url
Script copies stable branch content to /tags/release/1.2.3/01, where 01 is incremental build number.
Stable branch is chosen automatically:
- 1.x for major release 1.0.0
- 1.x for minor release 1.2.0
- 1.2.x for subminor release 1.2.3
Exports tags content and posts it via HTTP to WebDAV server.
svn-build -t http://svn.rutube.ru/project -i project-1.2.3
match is package name prefix, 1.2.3 is version to release. Script will upload to server last tag build.
- -i interactive mode, asks before commits
- -c config file (see below)
- -t SVN project root url
Computes stable name from version name
version-stable -a 1.2.3
With -a key will list major and minor stables for this version.
Prepares environment and deploys project to local path.
bbt-deploy -d production project
"project" is project name used in paths. "production" is deploy type:
- production will deploy to /data/, create virtualenv there and install packages from requires.txt
- devel will deploy to current directory, create virtualenv and install extra packages from requires.dev.txt
- test will deploy to current directory, create virtualenv and install extra packages from requires.test.txt
- tools installs extra python packages used by other BBT tools.
Under the hood of this script is make command with BBT makefile bamboo/Makefile. See makefile explanation for futher info.
- -c config file (see below)
- -d deploy type (explained earlier)
- -g use gmake (for FreeBSD)
- -l install virtualenv locally to
cwd
/virtualenv - -s path to project source dir
Runs tests and collects interesting statistics for Bamboo.
bbt-test -t django project
"project" is project name used in paths. "djando" is unittest type:
- django run Django unittests
- twisted run Twisted unittests
- unittest run python unittests (TBD)
- -c config file (see below)
- -t unittest type (explained earlier)
- -o collect coverage info
- -g use gmake (for FreeBSD)
- -l usr virtualenv locally in
cwd
/virtualenv - -s path to project source dir
Transforms coverage.py xml report to Atlassian Clover test report format understood by Bamboo.
coverage2clover -i input.xml -o output.xml
cat input.xml | coverage2clover > output.xml
Outputs a list of tasks found by several criteries:
- -t task type (i.e. "Development Task")
- -s task status ("i.e. "Developing")
- -u current assignee (i.e. "username" or "currentUser()")
- -r release name (fixVersion, i.e. "1.2.3")
task-search -u currentUser() -t "Development Ticket" -t "Development Subtask" -s "Integrating" -r "1.2.3" PROJ
"PROJ" is JIRA project key
- -c config file (see below)
Output a list of unreleased and not archived versions linked to task.
task-versions PROJ-6
- -c config file (see below)
Assigns a task to "currentUser()" with -m flag or to other.
task-assign -m PROJ-5
task-assign PROJ-6 username
- -c config file (see below)
Transit task over workflow
task-transition PROJ-6 developed
"developed" is allowed task status name.
- -c config file (see below)
Python-style config file for Bamboo Build Tools.
# requirements filenames lists by deploy type
requires = {
'DEPLOY': ('requires.part1.txt', 'requires.part2.txt'),
'DEVEL': ('requires.dev.txt'),
'TEST': ('requires.test.txt')
}
# additional include files
include = ('include1.mk', 'include2.mk')
# additional make targets called after deploy
extra_targets = {
'PRODUCTION': (),
'DEVEL': (),
'TEST': (),
}
# JIRA credentionals
jira_user = 'bamboo'
jira_password = 'password'
# WebDAV url for package upload
repo_url = 'http://localhost/webdav'
# JIRA project key
project_key = 'PROJ'
# SVN project root
project_root = 'http://svn.example.org/repo/project/'