@@ -49,12 +49,6 @@ def build_add_content(
4949 :param content_guids_with_bundle: Union[tuple[models.ContentGuidWithBundle], list[models.ContentGuidWithBundle]]
5050 """
5151 build_store = ensure_content_build_store (connect_server )
52- if build_store .get_build_running ():
53- raise RSConnectException (
54- "There is already a build running on this server, "
55- + "please wait for it to finish before adding new content."
56- )
57-
5852 with RSConnectClient (connect_server ) as client :
5953 if len (content_guids_with_bundle ) == 1 :
6054 all_content = [client .content_get (content_guids_with_bundle [0 ].guid )]
@@ -104,10 +98,6 @@ def build_remove_content(
10498 _validate_build_rm_args (guid , all , purge )
10599
106100 build_store = ensure_content_build_store (connect_server )
107- if build_store .get_build_running ():
108- raise RSConnectException (
109- "There is a build running on this server, " + "please wait for it to finish before removing content."
110- )
111101 guids : list [str ]
112102 if all :
113103 guids = [c ["guid" ] for c in build_store .get_content_items ()]
@@ -141,10 +131,23 @@ def build_start(
141131 all : bool = False ,
142132 poll_wait : int = 1 ,
143133 debug : bool = False ,
134+ force : bool = False ,
144135):
145136 build_store = ensure_content_build_store (connect_server )
146- if build_store .get_build_running ():
147- raise RSConnectException ("There is already a build running on this server: %s" % connect_server .url )
137+ if build_store .get_build_running () and not force :
138+ raise RSConnectException (
139+ "There is already a build running on this server: %s. "
140+ "Use the '--force' flag to override this check." % connect_server .url
141+ )
142+
143+ # prompt the user to confirm that they want to --force a build.
144+ if force :
145+ logger .warning ("Please ensure a build is not already running in another terminal before proceeding." )
146+ user_input = input ("Are you sure you want to proceed? Type 'yes' to confirm: " ).strip ().lower ()
147+ if user_input != "yes" :
148+ logger .warning ("Build aborted." )
149+ return
150+ logger .info ("Proceeding with the build operation..." )
148151
149152 # if we are re-building any already "tracked" content items, then re-add them to be safe
150153 if all :
@@ -154,7 +157,8 @@ def build_start(
154157 build_add_content (connect_server , all_content )
155158 else :
156159 # --retry is shorthand for --aborted --error --running
157- if retry :
160+ # --force has the same behavior as --retry and also ignores when rsconnect_build_running=true
161+ if retry or force :
158162 aborted = True
159163 error = True
160164 running = True
@@ -277,12 +281,12 @@ def _monitor_build(connect_server: RSConnectServer, content_items: list[ContentI
277281 )
278282
279283 if build_store .aborted ():
280- logger .warn ("Build interrupted!" )
284+ logger .warning ("Build interrupted!" )
281285 aborted_builds = [i ["guid" ] for i in content_items if i ["rsconnect_build_status" ] == BuildStatus .RUNNING ]
282286 if len (aborted_builds ) > 0 :
283- logger .warn ("Marking %d builds as ABORTED..." % len (aborted_builds ))
287+ logger .warning ("Marking %d builds as ABORTED..." % len (aborted_builds ))
284288 for guid in aborted_builds :
285- logger .warn ("Build aborted: %s" % guid )
289+ logger .warning ("Build aborted: %s" % guid )
286290 build_store .set_content_item_build_status (guid , BuildStatus .ABORTED )
287291 return False
288292
0 commit comments