Closed d2lam closed 6 years ago
Verifying that it works: https://cd.screwdriver.cd/pipelines/122/builds/3708
The step exit fails, but it still runs the step stuff
(since alwaysRun is set to true for this step) and also runs the bookend:
One thing is that the status of these steps are Failure
. I think we should make those steps (for example, stuff
and artifact-bookend
) to be Success if runs successfully, while keeping the build status as Failure.
I can dig into this more if that is the expected behavior.
Yeah, this should definitely keep the correct step status.
Actually this is not working. Those steps were not run successfully (returning code 254). Need to look into this more.
@minz1027 and I did some investigation on this.
EXIT
to echo an extra line for STEP_ID
before exiting. However, it does not prevent the shell from exiting. alwaysRun
is true
(Notice how update step status is called for stuff
, but not what
). However, since the shell already exits, subsequent steps will not be able to execute. Consulted with @rphan about this.
The trap route would not work for us.
One way that could get this work is to have a wrapper script and this script would run all the steps.
In wrapper.sh
:
. /tmp/step1.sh
. /tmp/step2.sh # if this step fails, step3 will still run
. /tmp/step3.sh
However, this will require a lot of refactor in launcher
. Currently, each command is fed into the pty
like this: https://github.com/screwdriver-cd/launcher/blob/master/executor/executor.go#L83
A few concerns:
sh
won't work. We need to switch to bash
@stjohnjohnson are we ok with this? I remember we didn't want to use bash
because sh
is more standard. wrapper.sh
that includes all the step scripts, we need to handle the update step status in between steps. And we would need to do this in script instead of go
. @petey we should figure out the priority on this. It's going to be a big change. If we choose to not implement this yet, should we roll back the change? Technically, it won't affect anything. The alwaysRun
would just not work.
Discussed with the team and decided to roll back this feature. We should revisit this later.
Reason to roll back: based on current implementation of launcher, it's impossible to stay in the shell if the step fails & exits.
Update Dec 8, 2017 Taking another stab at this, following some of the ideas here: https://github.com/screwdriver-cd/screwdriver/blob/master/design/director.md
PR is opened: https://github.com/screwdriver-cd/launcher/pull/133
Implementation details:
This now works as expected. Thanks @d2lam @minz1027
Currently, if the build fails in the middle, bookends would not be executed. This shouldn't be the case. For example, if users store some deploy logs in the artifact folder. If the build breaks, they need to be able to look at the logs to debug. However, the
screwdriver-artifact-bookend
won't run since the build breaks.