Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

The after-script commands are not running at all on some pipelines

Konstantinos September 3, 2022

The after-script section in the following custom pipeline is never triggered:

pipelines:
custom:
test-job:
- step:
name: Run Postman
image: alpine:3.15
script:
- apk add npm bash
- npm install -g newman
- echo "This runs"
after-script:
- echo "This doesn't run"

Although the following works:

pipelines:
custom:
test-job:
- step:
name: Run Postman
image: alpine:3.15
script:
- echo "This runs"
after-script:
- echo "This also runs" 

This seems like a pipeline bug to me. Any ideas what might be causing this?

1 answer

1 vote
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 4, 2022

Hey @Konstantinos 

Welcome to the community!

I tested and verified that this issue is only reproducible on the alpine image and other docker image works fine.

Further investigation, I found out that this was caused by the command

add npm bash  

The root cause it's a little complex, but the simplified version is before we start the build, we will try to check if `/bin/bash` existed or not. If yes, we add a special redirection command in "~/.bashrc" to make the output redirect correctly.

However, because alpine does not have a `/bin/bash` build-in, we don't put that file in the image, and when the user installs bash in the build script, our after build script would find "/bin/bash" and execute after build script in bash context. It would miss the log because it doesn't have `~/.bashrc` in place, so it doesn't redirect properly.

There are two suggestion to fix it, which is:

  • Don't install bash
  • Use an image that already has bash installed.

I hope this helps. 

Cheers,
Syahrul

Konstantinos September 4, 2022

Hi @Syahrul ,

Thanks a lot for the explanation. Is there a way to submit a bug report for this issue?

Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 5, 2022

Hi @Konstantinos 

I don't classify this as a bug because it's expected behavior, and this is more towards a feature since the issue happens because the alpine image doesn't include `/bin/bash` in their image.

I would suggest you raise the feature with the alpine team here .

Cheers,
Syahrul

Konstantinos September 7, 2022

@SyahrulI still believe this is a bug due to the following reasons:

- The shell used on the image shouldn't interact in any way with the CI. The same jobs work fine on all other major CI solutions (github, gitlab, circleci). Bitbucket is the odd one out here.

- If this is expected behavior are there any docs? The job fails silently without an error message and the user isn't able to debug on their own.

Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 8, 2022

Hi @Konstantinos 

Apologize for the confusion. It makes more sense to have an error message on the build log.

I did check with our devs team and found out that we already have an existing bug report on this at:

I highly suggest you Vote and click This affects my team so that you'll receive an update whenever we have any in the future.

Cheers,
Syahrul

Suggest an answer

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

Atlassian Community Events