tbuilddel.py - devuan-releasebot - devuan's releasebot reimplemented (scorsh version)
HTML git clone git://parazyd.org/devuan-releasebot.git
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tbuilddel.py (1266B)
---
1 #!/usr/bin/env python3
2 # See LICENSE file for copyright and license details.
3
4 """
5 Module to delete Jenkins build jobs
6 """
7
8 import sys
9 from os import environ as env
10 from os.path import basename, dirname
11 import jenkins
12
13 from config import (jenkins_user, jenkins_pass, jenkins_host, jobtypes,
14 dryrun)
15
16
17 def main():
18 """
19 Main function
20 """
21 print('* Requested job deletion')
22
23 print('- Connecting to Jenkins...')
24 jenk = jenkins.Jenkins(jenkins_host, jenkins_user, jenkins_pass)
25
26 try:
27 jenk.get_whoami()
28 except jenkins.JenkinsException:
29 print('Error in request. Possible authentication fail.')
30 sys.exit(1)
31
32 # the -4 cuts off '.git' from the path
33 pkgname = basename(env['SCORSH_REPO'])[:-4]
34 for jobt in jobtypes:
35 jobname = '-'.join([pkgname, jobt])
36
37 print('* Trying to delete %s job for %s' % (jobt, pkgname))
38
39 if not jenk.job_exists(jobname):
40 print('* %s does not exist in Jenkins' % jobname)
41 continue
42
43 print('- Deleting job')
44 if not dryrun:
45 jenk.delete_job(jobname)
46
47
48 if __name__ == '__main__':
49 if len(sys.argv) > 1:
50 main()
51 else:
52 print('Error: not enough arguments')
53 sys.exit(1)