]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/buildbot/projects/nicecoop/__init__.py
1 from buildbot
.plugins
import *
2 from buildbot_common
.build_helpers
import *
4 from buildbot
.util
import bytes2unicode
6 from functools
import partial
8 __all__
= [ "configure", "E" ]
12 BUILDBOT_URL
= "https://git.immae.eu/buildbot/{}/".format(PROJECT
)
13 SOCKET
= "unix:/run/buildbot/{}.sock".format(PROJECT
)
14 PB_SOCKET
= "unix:address=/run/buildbot/{}_pb.sock".format(PROJECT
)
15 SSH_KEY_PATH
= "/var/lib/buildbot/buildbot_key"
16 SSH_HOST_KEY
= "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFbhFTl2A2RJn5L51yxJM4XfCS2ZaiSX/jo9jFSdghF"
18 GESTION_GIT_URL
= "gitolite@git.immae.eu:perso/Immae/Projets/Nicecoop/GestionCompte"
19 GESTION_RELEASE_PATH
= "/var/lib/buildbot/outputs/nicecoop/gestion"
22 SECRETS_FILE
= os
.getcwd() + "/secrets"
23 LDAP_URL
= "ldaps://ldap.immae.eu:636"
24 LDAP_ADMIN_USER
= "cn=buildbot,ou=services,dc=immae,dc=eu"
25 LDAP_BASE
= "dc=immae,dc=eu"
26 LDAP_PATTERN
= "(uid=%(username)s)"
27 LDAP_GROUP_PATTERN
= "(&(memberOf=cn=groups,ou=immaeEu,cn=buildbot,ou=services,dc=immae,dc=eu)(member=%(dn)s))"
28 TITLE_URL
= "https://www.immae.eu"
32 c
["buildbotURL"] = E
.BUILDBOT_URL
33 c
["www"]["port"] = E
.SOCKET
35 worker_name
= "generic-worker-nicecoop"
36 c
['workers'].append(worker
.LocalWorker(worker_name
))
38 c
['schedulers'].append(git_hook_scheduler("Gestion", ["GestionProduction", "GestionSandbox"]))
39 c
['schedulers'].append(force_scheduler("force_nicecoop", ["GestionProduction", "GestionSandbox"]))
40 c
['builders'].append(util
.BuilderConfig(name
="GestionProduction", workernames
=[worker_name
], factory
=gestion_factory("production")))
41 c
['builders'].append(util
.BuilderConfig(name
="GestionSandbox", workernames
=[worker_name
], factory
=gestion_factory("sandbox")))
43 def gestion_factory(env
):
45 "PATH": "/run/current-system/sw/bin"
48 factory
= util
.BuildFactory()
49 factory
.addStep(steps
.Git(logEnviron
=False, repourl
=E
.GESTION_GIT_URL
,
50 submodules
=True, sshPrivateKey
=open(E
.SSH_KEY_PATH
).read().rstrip(),
51 sshHostKey
=E
.SSH_HOST_KEY
, mode
="full", method
="fresh"))
52 factory
.addStep(steps
.FileDownload(mastersrc
="/run/current-system/nicecoop/gestion/{}.tar.gz".format(env), workerdest="{}.tar.gz".format(env
)))
53 factory
.addStep(steps
.ShellCommand(name
="cleanup files",
54 logEnviron
=False, haltOnFailure
=False, command
="rm -rf ../{}_app".format(env
)))
55 factory
.addStep(steps
.ShellCommand(name
="extract files",
56 logEnviron
=False, haltOnFailure
=True, env
=path_env
, command
="tar -C .. -xzf {}.tar.gz".format(env
)))
57 factory
.addStep(steps
.ShellCommand(name
="make files writeable",
58 logEnviron
=False, haltOnFailure
=True, workdir
="{}_app".format(env
), command
="chmod -R u+w ."))
59 factory
.addStep(steps
.ShellCommand(name
="remove symlinks",
60 logEnviron
=False, haltOnFailure
=True, workdir
="{}_app".format(env
),
61 command
="rm var app/config/parameters.yml"))
62 factory
.addStep(NixShellCommand(name
="copy parameters",
63 logEnviron
=False, haltOnFailure
=True, env
=path_env
,
64 command
="cat {0}/parameters.yml | gucci -f /var/secrets/buildbot/nicecoop/{0}.yml > ../{0}_app/app/config/parameters.yml".format(env
)))
65 factory
.addStep(steps
.ShellCommand(name
="test configuration",
66 logEnviron
=False, haltOnFailure
=True, workdir
="{}_app".format(env
), command
="./bin/console --env=prod -q"))
67 factory
.addStep(steps
.FileUpload(workersrc
="../{}_app/app/config/parameters.yml".format(env
),
68 masterdest
=E
.GESTION_RELEASE_PATH
+ "/{}/parameters.yml".format(env
)))