flosell / lambdacd

a library to define a continuous delivery pipeline in code
https://www.lambda.cd/
Apache License 2.0
677 stars 59 forks source link

Retrigger step does not keep context #177

Open magnars opened 6 years ago

magnars commented 6 years ago

Thanks for making a cool project. LambdaCD is just what I was looking for.

When retriggering a step in a build, a new build is started from that point. However, since the context changes, the files generated by earlier steps are missing.

This might not be a bug, but it did break my expectations. :-)

I would expect the old context to be reused in the new build, so that I could try a broken build again.

What am I missing?

flosell commented 6 years ago

Thanks for the feedback! You hit one of the rough spots where I haven't figured out a good solution yet (and I'd be happy for ideas).

To answer your question first: If I understand you correctly (please correct me if I'm wrong) your scenario is similar to the one described in #36 so maybe the solution introduced there (marking some steps so they can't be retriggered) can at least resolve some confusion when using the pipeline. There's a bit more on this deep in the documentation. On top of that, you might be able to work around the problem by changing your pipeline or approach: Retrigger the parent of the step (e.g. workspace) so that all your steps (including the one that generates the files) are retriggered. Put the files you need on an artifact store and pull them back whenever you need them (maybe lambdacd-artifacts is good enough if you don't have/want a proper artifact store.

But your question also prompted me to think about this problem again after a while so maybe there's a way to improve LambdaCD to support this better:

magnars commented 6 years ago

Thanks for your in-depth answer! Yes, my scenario does seem like the same that is described in #36. I think the point about steps running arbitrary code illustrates well why this is a hard problem.

To be clear what my use case was:

So running from an earlier step wouldn't help me. And it wasn't a big deal either. But my intuition about how the retriggering would work was a bit off. :)

I am a bit curious: What use cases you have for the retriggering the way it works now?

crimeminister commented 6 years ago

I have found that adding an immutable fileset to a pipeline can improve things with respect to build output. There's still housekeeping to do w.r.t. artifacts but using filesets makes it easy to do so in a functionally idiomatic way.

flosell commented 6 years ago

@crimeminister filesets look really interesting, thanks for the suggestion! Do you have an example what that looks like in an actual pipeline?

@magnars I have seen a lot of people write pipelines where a single step runs unit-tests and builds a complete artifact (jar, Docker image) and then has subsequent steps to deploy to environments and run additional tests against those. There, retriggering isn't too much of a problem since the steps are more self contained (and slower).

But I'd actually prefer your approach of more fine grained steps that might depend on each other, both for speed of development and visibility so I'll definitely keep this issue open to find a way how LambdaCD can support this better.

magnars commented 6 years ago

Thanks for the clarification, that makes sense. I'm glad to hear that you want to support smaller steps as well. :)