Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Managetests
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Managetests
Commits
b7467053
Commit
b7467053
authored
May 01, 2018
by
Pietro Albini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fail the build if a command fails
parent
210ebf52
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
managetests/branches.py
managetests/branches.py
+18
-6
No files found.
managetests/branches.py
View file @
b7467053
...
...
@@ -21,7 +21,7 @@ import shutil
import
json
BRANCH_DIR_VERSION
=
"
3
"
BRANCH_DIR_VERSION
=
"
4
"
class
Branch
:
...
...
@@ -82,7 +82,7 @@ class Branch:
return
False
# All the files must be be present
files
=
[
"version"
,
"commit"
,
"config.json"
]
files
=
[
"version"
,
"commit"
,
"
built"
,
"
config.json"
]
for
file
in
files
:
file
=
root
/
file
if
not
(
file
.
exists
()
and
file
.
is_file
()):
...
...
@@ -162,7 +162,7 @@ class Branch:
def
exec_command
(
self
,
raw_command
,
replaces
=
None
,
build
=
False
):
"""Exec a command in the context of the branch"""
args
,
kwargs
=
self
.
command_popen_args
(
raw_command
,
replaces
,
build
)
return
subprocess
.
call
(
*
args
,
**
kwargs
)
return
subprocess
.
call
(
*
args
,
**
kwargs
)
==
0
def
command_popen_args
(
self
,
raw_command
,
replaces
=
None
,
build
=
False
):
"""Get the Popen arguments for exec_command"""
...
...
@@ -261,11 +261,17 @@ class Branch:
# Build the website
for
cmd
in
self
.
config
[
"build"
]:
self
.
exec_command
(
cmd
,
build
=
True
)
if
not
self
.
exec_command
(
cmd
,
build
=
True
):
log
(
"[!] Failed to execute build command: %s"
%
" "
.
join
(
cmd
))
log
(
"[!] Aborting!"
)
return
False
# Execute the pre-install commands
for
cmd
in
self
.
config
[
"before_install"
]:
self
.
exec_command
(
cmd
,
build
=
True
)
if
not
self
.
exec_command
(
cmd
,
build
=
True
):
log
(
"[!] Failed to execute before_install command: %s"
%
" "
.
join
(
cmd
))
log
(
"[!] Aborting!"
)
return
False
# Install the builded artifacts
total
=
0
...
...
@@ -284,7 +290,10 @@ class Branch:
# Execute the post-install commands
if
"after_install"
in
self
.
config
:
for
cmd
in
self
.
config
[
"after_install"
]:
self
.
exec_command
(
cmd
,
build
=
True
)
if
not
self
.
exec_command
(
cmd
,
build
=
True
):
log
(
"[!] Failed to execute after_install command: %s"
%
" "
.
join
(
cmd
))
log
(
"[!] Aborting!"
)
return
False
# Check if the branch was successifully built
popen_args
=
self
.
command_popen_args
(
self
.
config
[
"run"
])
...
...
@@ -301,6 +310,9 @@ class Branch:
self
.
manager
.
details
[
"branches"
][
self
.
name
]
=
self
.
mr
self
.
manager
.
save_details
()
# Create the built file
(
branch
/
"built"
).
touch
()
self
.
_deploying
=
False
def
destroy
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment