Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
conda
fsl-ci-rules
Commits
3e047d50
Commit
3e047d50
authored
Oct 04, 2021
by
Paul McCarthy
🚵
Browse files
RF: Don't try and trigger deploy on a failed build
parent
72a01f51
Changes
1
Show whitespace changes
Inline
Side-by-side
fsl_ci/utils/trigger_build.py
View file @
3e047d50
...
...
@@ -7,10 +7,12 @@
#
import
sys
import
os.path
as
op
import
functools
as
ft
import
textwrap
as
tw
import
argparse
import
datetime
import
multiprocessing.dummy
as
mp
from
fsl_ci.recipe
import
get_recipe_variable
...
...
@@ -32,6 +34,11 @@ SERVER_URL = 'https://git.fmrib.ox.ac.uk'
"""Default gitlab instance URL, if not specified on the command.line."""
def
now
():
"""Returns the current time as a string. """
return
datetime
.
datetime
.
now
().
strftime
(
'%H:%M:%S'
)
def
get_revision
(
recipe_path
,
server
,
token
):
"""Return the value of the FSLCONDA_REVISION variable on the given
conda recipe repository, or None if it is not set.
...
...
@@ -85,7 +92,7 @@ def trigger_build(project, server, token, production):
pid
=
pipeline
[
'id'
]
print
(
f
'Pipeline triggered on
{
project
}
(
{
channel
}
build) '
print
(
f
'
{
now
()
}
Pipeline triggered on
{
project
}
(
{
channel
}
build) '
f
'- see
{
pipeline
[
"web_url"
]
}
'
)
try
:
...
...
@@ -93,7 +100,7 @@ def trigger_build(project, server, token, production):
except
Exception
:
return
None
print
(
f
'Build pipeline for
{
project
}
has finished:
{
status
}
'
)
print
(
f
'
{
now
()
}
Build pipeline for
{
project
}
has finished:
{
status
}
'
)
if
status
!=
'manual'
:
return
None
...
...
@@ -106,6 +113,11 @@ def trigger_deploy(project, pid, server, token, production):
and waits for it to complete.
"""
# trigger_build returns None
# if the build failed
if
pid
is
None
:
return
False
# deployment to staging/production gets set at
# build time, so we don't need to pass the STAGING
# variable here, like we do in trigger_build
...
...
@@ -116,7 +128,7 @@ def trigger_deploy(project, pid, server, token, production):
meta
=
load_meta_yaml
(
meta
)
platforms
=
get_platform_ids
(
meta
)
print
(
f
'Triggering deploy-
{
platforms
}
-conda-package jobs '
print
(
f
'
{
now
()
}
Triggering deploy-
{
platforms
}
-conda-package jobs '
f
'on
{
project
}
(deploying to
{
channel
}
channel)'
)
try
:
...
...
@@ -128,9 +140,11 @@ def trigger_deploy(project, pid, server, token, production):
trigger_job
(
project
,
j
[
'id'
],
server
,
token
)
status
=
wait_on_pipeline
(
project
,
pid
,
server
,
token
)
print
(
f
'Deploy job
{
project
}
has finished:
{
status
}
'
)
print
(
f
'
{
now
()
}
Deploy job
{
project
}
has finished:
{
status
}
'
)
return
True
except
Exception
as
e
:
print
(
f
'Error triggering deploy job on
{
project
}
:
{
e
}
'
)
return
False
def
parseArgs
(
argv
=
None
):
...
...
@@ -183,19 +197,22 @@ def main(argv=None):
server
=
args
.
server
,
token
=
args
.
token
,
production
=
args
.
production
)
result
=
True
if
args
.
sequential
:
for
project
in
projects
:
pid
=
build
(
project
)
deploy
(
project
,
pid
)
if
not
deploy
(
project
,
pid
):
result
=
False
else
:
pool
=
mp
.
Pool
(
len
(
projects
))
pids
=
pool
.
map
(
build
,
projects
)
pool
.
starmap
(
deploy
,
zip
(
projects
,
pids
))
result
=
all
(
pool
.
starmap
(
deploy
,
zip
(
projects
,
pids
))
)
pool
.
close
()
pool
.
join
()
return
0
if
result
else
1
if
__name__
==
'__main__'
:
main
()
sys
.
exit
(
main
()
)
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