@@ -27,6 +27,12 @@ class JenkinsCli(object):
2727
2828 QUEUE_EMPTY_TEXT = "Building Queue is empty"
2929
30+ INFO_TEMPLATE = ("Last build name: %s (result: %s)\n "
31+ "Last success build name: %s\n "
32+ "Build started: %s\n "
33+ "Building now: %s\n "
34+ "%s branch set to: %s" )
35+
3036 def __init__ (self , args , timeout = socket ._GLOBAL_DEFAULT_TIMEOUT ):
3137 self .jenkins = self .auth (args .host , args .username , args .password , timeout )
3238
@@ -116,25 +122,20 @@ def info(self, args):
116122 job_info = {}
117123 last_build = job_info .get ('lastBuild' , {})
118124 last_success_build = job_info .get ('lastSuccessfulBuild' , {})
119- info = ("Last build name: %s (result: %s)\n "
120- "Last success build name: %s\n "
121- "Build started: %s\n "
122- "Building now: %s\n "
123- "%s branch set to: %s" )
124125 xml = self .jenkins .get_job_config (job_name )
125126 root = ElementTree .fromstring (xml .encode ('utf-8' ))
126127 scm_name , branch_node = self ._get_scm_name_and_node (root )
127128 if branch_node is not None :
128129 branch_name = branch_node .text
129130 else :
130131 branch_name = 'Unknown branch'
131- print (info % (last_build .get ('fullDisplayName' , 'Not Built' ),
132- last_build .get ('result' , 'Not Built' ),
133- last_success_build .get ('fullDisplayName' , 'Not Built' ),
134- datetime .datetime .fromtimestamp (last_build ['timestamp' ] / 1000 ) if last_build else 'Not built ' ,
135- 'Yes' if last_build .get ('building' ) else 'No' ,
136- scm_name ,
137- branch_name ))
132+ print (self . INFO_TEMPLATE % (last_build .get ('fullDisplayName' , 'Not Built' ),
133+ last_build .get ('result' , 'Not Built' ),
134+ last_success_build .get ('fullDisplayName' , 'Not Built' ),
135+ datetime .datetime .fromtimestamp (last_build ['timestamp' ] / 1000 ) if last_build else 'Not Built ' ,
136+ 'Yes' if last_build .get ('building' ) else 'No' ,
137+ scm_name ,
138+ branch_name ))
138139
139140 def set_branch (self , args ):
140141 job_name = self ._check_job (args .job_name )
0 commit comments