Implement repa rebuild submcommand
authorEd Bartosh <eduard.bartosh@intel.com>
Sun, 1 Feb 2015 14:12:08 +0000 (16:12 +0200)
committerEd Bartosh <eduard.bartosh@intel.com>
Tue, 3 Feb 2015 11:52:19 +0000 (13:52 +0200)
repa rebuild triggers re job on jenkins with action=rebuild.

Fixes: #2322
Change-Id: I5a18aeb441eeb608d3015e131d150665cd6992a1
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
repa.1
repa/rebuild.py [new file with mode: 0644]
setup.py

diff --git a/repa.1 b/repa.1
index 099d2a0b5410bea012a619199713ca178c91cbf8..bbbe2622ca411dc42ff01fc21857930292aaa0b1 100644 (file)
--- a/repa.1
+++ b/repa.1
@@ -46,6 +46,9 @@ Submission group is a temporary group of submissions, created for testing purpos
 .RS 2
 7. \fBdiff\fR - show the difference between projects
 .RE
+.RS 2
+8. \fBrebuild\fR - rebuild submission
+.RE
 
 .\" ===========================================================================
 .\" Global options
@@ -359,6 +362,37 @@ Print short help text about the "diff" command and exit.
 .RE
 
 
+.\"
+.\" The "rebuild" command description
+.\"
+.SS \fBrebuild\fR [options] <submision>
+
+.RS 2
+Rebuild submission by triggering 're' Jenkins job. 're' job triggering rebuild by re-exports packages in submission. By default it re-exports all packages. It's also possible to re-export only one package using --package command line option.
+
+.\"
+.\" The "rebuild" command's options
+.\"
+.RS 2
+\fBOPTIONS\fR
+.RS 2
+.B \-h, \-\-help
+.RS 2
+Print short help text about the "rebuild" command and exit.
+.RE
+
+.PP
+.B \-c \-\-comment COMMENT
+.RS 2
+Provide a comment with the explanation of a reason for rebuild. Mandatory option.
+.RE
+
+.PP
+.B \-p \-\-package <package name>
+.RS 2
+Rebuild only one package.
+.RE
+
 .SH CONFIGURATION FILE
 
 .RS 2
diff --git a/repa/rebuild.py b/repa/rebuild.py
new file mode 100644 (file)
index 0000000..d79b823
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+#
+# This file is part of REPA: Release Engineering Process Assistant.
+#
+# Copyright (C) 2015 Intel Corporation
+#
+# REPA is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# version 2 as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+"""
+REPA: Release Engineering Process Assistant.
+
+Copyright (C) Intel Corporation 2015
+Licence: GPL version 2
+Author: Ed Bartosh <eduard.bartosh@intel.com>
+
+Rebuild module.
+Rebuild submissions.
+"""
+
+import sys
+
+from collections import namedtuple
+
+from repa.main import sub_main
+from repa.jenkins import trigger_build
+
+class Rebuild(object):
+    """Subcommand: rebuild submissions."""
+
+    name = 'rebuild'
+    description = 'Rebuild submission'
+    help = description
+
+    @staticmethod
+    def add_arguments(parser, _):
+        """Adds arguments to the parser. Called from [sub_]main."""
+        parser.add_argument('submission', help='submission')
+        parser.add_argument('-p', '--package', help='package')
+        parser.add_argument('-c', '--comment', help='comment', required=True)
+
+    @staticmethod
+    def run(argv):
+        """Command line entry point. Called from [sub_]main."""
+        job = 're'
+        cred = namedtuple('cred', ['url', 'username', 'password'])(\
+                   argv.jenkins_url, argv.jenkins_user, argv.jenkins_passwd)
+        build, status, out = \
+            trigger_build(job, {'action': 'rebuild',
+                                'submission': argv.submission,
+                                'package': argv.package,
+                                'target_project': argv.project,
+                                'comment': argv.comment}, cred)
+        print "Jenkins job: %s, build #%s, status: %s" % (job, build, status)
+        print out
+        return status == 'SUCCESS'
+
+if __name__ == '__main__':
+    sys.exit(sub_main(sys.argv[1:], Rebuild()))
index 34c371fb0865c202b648ac43f01da3ecf748d082..b4b012cef979271715ef066038d176fc1873fddb 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -48,5 +48,6 @@ setup(name="repa",
                               'reject = repa.reject:Reject',
                               'rmgroup = repa.rmgroup:RmGroup',
                               'show = repa.show:Show',
-                              'diff = repa.diff:Diff']
+                              'diff = repa.diff:Diff',
+                              'rebuild = repa.rebuild:Rebuild']
       })