File: fabfile.py

package info (click to toggle)
jenkins-debian-glue 0.23.6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 416 kB
  • sloc: sh: 2,636; ruby: 543; makefile: 30; python: 24
file content (41 lines) | stat: -rw-r--r-- 1,283 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
################################################################################
# Deploy Debian package to jenkins build system(s)
#
# Usage examples:
# % fab all
# % fab build && fab deploy
# % fab -H root@jenkins.example.org deploy
################################################################################

from fabric.api import *
import os, paramiko, sys

def set_hosts():
    if not env.hosts:
        env.hosts = []

        for host in 'jenkins', 'jenkins-slave1', 'jenkins-slave2', 'jenkins-slave3', 'jenkins-slave4', 'jenkins-slave5', 'jenkins-slave6':
            config = paramiko.SSHConfig()
            config.parse(open(os.path.expandvars("$HOME") + '/.ssh/config'))
            h = config.lookup(host)
            env.hosts.append(h['user'] + "@" + h['hostname'])

    return env.hosts

@runs_once
def build():
    local('rm -f ../jenkins-debian-glue*all.deb')
    local('fakeroot debian/rules clean')
    local('fakeroot debian/rules binary')
    local('fakeroot debian/rules clean')

@hosts(set_hosts())
def deploy():
    put('../jenkins-debian-glue*_all.deb', '~/')
    run('dpkg -i ~/jenkins-debian-glue*_all.deb || apt-get -f install')

def all():
    build()
    deploy()

## END OF FILE #################################################################