I need something like a teardown step

Dittmar_ Dirk July 12, 2024

Hello,

 

we're currently migrating from Bamboo. Bamboo had "final tasks" ... these tasks are fired even if the "normal" tasks were failing.

I'm looking for a replacement. I'm starting some docker containers on a remote maschine and have to stop them afterwards.

I'm thinking of something like "teardown steps" but couldn't find anythink like that.

Any Ideas?

 

Regards,

 

Dirk

2 answers

0 votes
Dittmar_ Dirk July 18, 2024

There is an suggestion for this: Need for an "after-step" 

0 votes
Nicolas Grossi
Banned
July 12, 2024
Dittmar_ Dirk July 12, 2024

Hi, no... but kind of (I guess)

The "after-script" is run after the the "script" in the step...

I'm looking for a step after all the steps... I'm thinking of something like:

 

pipelines:
custom:
nightly-integration-tests:
- stage:
steps:
- step:
runs-on:
- self.hosted
- linux
name: "start docker containers"
image: atlassian/default-image:4
script:
- |
ssh -o "StrictHostKeyChecking no" foo@bar 'bash -s' < start-postgres15-and-solr.sh
- step:
runs-on:
- self.hosted
- linux
name: "run the integration tests"
image: maven:3.9.5-eclipse-temurin-17-focal
script:
- |
mvn ...
- step: # or something like "after-steps"
runs-on:
- self.hosted
- linux
name: "shutdown docker containers"
image: atlassian/default-image:4
script:
- |
ssh -o "StrictHostKeyChecking no" foo@bar 'bash -s' < stop-all-docker-containers.sh
Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2024

Hi @Dittmar_ Dirk 

Can you start the container as part of "run integration tests" and use `after-script` on that step to stop it?

Dittmar_ Dirk July 14, 2024

Hi, no...

the "run the integration tests" is a step where I run a Maven3 build. The other steps use an image where I can run SSH "things". I could shove everything in one image but than I have to nurse that image myself... and where is the sense of the "steps" and stages then?

Maybe I can do something with conditions (or something like that)? 🤔 

Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2024

Yeah, I see... You mean start conditions? 🤔

Dittmar_ Dirk July 15, 2024

... yes ... but that's only for conditions like "do this if files in some directory were changed" ... and the step is not executed because the pipeline stops at the step that has a non zero return code...

Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2024

hmm... yeah, the failure scenario would not work.

What you use 'after-script' with trigger-pipe?

Set a `after-script` on every step after the setup and, check whether it has failed and trigger a 'clean up' pipeline for the intermediate steps, and always trigger on the last step?

Like Dittmar_ Dirk likes this
Dittmar_ Dirk July 15, 2024

hmmm ... no, but I see the idea...

The second step (see above) uses `maven:3.9.5-eclipse-temurin-17-focal` which does not have an ssh-client like the image in the last step (`atlassian/default-image:4`)

I guess I have to stuff everything in one image and use one step only... kinda anoying really... where can I file a feature request?

Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2024

If you define a separated 'clean up' pipeline you can use the 'atlassian/default-image:4'. So you would have 'nightly-integration-tests' pipeline which triggers 'clean up'.

Usually Atlassian support monitors the posts here and create a request if it doesn't already exists.

Dittmar_ Dirk July 16, 2024

That's not a sulution ether ... I'm just testing with a one database but I have to build this for 5 other databases... like:

  • for every supported databases do:
    • for every supported version do:
      1. start the database (on our own host via ssh)
      2. run all the integration tests (with maven)
      3. shutdown the database (via ssh)

so... I guess there is no easy way to do it 🤷

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 16, 2024

Hi Dirk,

We have a feature request for an after-step here:

The request has been closed due to inactivity; no comments or votes for an extended period of time, so it didn't make it to the roadmap. However, you can still leave a comment with your use case to express your interest, as our product managers continue to monitor even closed requests.

The after-script is the only available option right now, and Saxea _Flowie_'s replies have covered what is possible.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events