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

Inline script ignores error

Ali Sahin April 18, 2019

Hi there,

quick question: I have an inline script step in my build process which basically calls

 

docker-compose build
docker-compose push

 

Today I figured in hindsight, that the build-command failed with

error	18-Apr-2019 13:29:45	Service 'xxx' failed to build: Error processing tar file(exit status 1): mkdir /var/www/html/: no space left on device

which is fine, but bamboo continued with the push and everything was shiny and green.

 

Why bamboo doesn't fail?

 

Thanks in advance.

1 answer

1 vote
Victor Debone
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 18, 2019

Hello @Ali Sahin, welcome to the community :)

In order to fail a build, an inline script must exit with a non-zero value.

If this error occurred inside Docker, or if I misunderstood the log, within the `docker-compose push` command. And regardless of the error, the command `docker-compose push` continued its execution, the Script task will not be able to understand the failure and stop the build. 

Did it help you?

Victor

Ali Sahin April 18, 2019

Hi Victor,

thanks for welcoming me.

The error did not occured inside a Docker. It occured on the build machine which indeed build the images. The build of one image failed and bamboo ignored that error and continued with 'docker-compose push'. 

My expectation is, that bamboo fails when an error occurs in 'docker-compose build'.

How am I able to detect this and return a non-zoer value?

 

Ali

Victor Debone
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 18, 2019

Ok, now I understand you better.

For this answer I assume you are running Bamboo in Linux. Because if you are running in Linux, your script task is running with bash, which makes sense from what you've described.

Bash scripts, if not altered or specified, will always exit with the exit code from the last command, which in your case is the `docker-compose push`. That is why Bamboo recognised it as a successful build, your `docker-compose push` worked.

Also, your script is defined in a way that regardless of the result of `docker-compose build`, the `docker-compose push` command will be run. So you probably want it to automatic exit it on error.

Alternatively, you could separate this task into two, and define an artifact to share the build result of `docker-compose`, and avoid the issue with errors getting lost in the script. 

Did it help you?

Victor

Ali Sahin April 18, 2019

Thanks for the link.

I seperated the task into two. Now I have to watch :-D


Thank you very much, Victor.

Like Victor Debone likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events