I am getting this error : Result: exit code = 2 SSH command failed. Failing build.

Doug Gordon February 1, 2025

Hi 

 

I have a deploy.yml file set up in a bitbucket repository that triggers a bamboo build using SAS.  I previously had a SSH key set up with bitbucket but due to a recent issue that has been disabled by admins.

 

The build keeps failing and I keep getting "Result: exit code = 2....... SSH command failed. Failing build." - I've revoked my bitbucket SSH key and revoked the http token but I'm no expert in SSH and I can't seem to work out why this is failing.

 

Any help appreciated.

2 answers

1 accepted

0 votes
Answer accepted
Doug Gordon February 3, 2025

I found that the exit code is a semi-generic code that seems to be related to a warning that the system created as it was running the code associated to my login credentials.  I changed a code file to point to a system account and it worked fine.  Seems like the SSH element related to Bamboo failing due to this warning.  Some reference material that suggests that the exit code is related to code failure would be useful, but I also understand that Bamboo isn't designed to interpret return codes for every software package that it services.  

 

So if you're using Bamboo to build and deploy SAS code, and you are getting this exit code, I'd suggest scanning the SAS logs for any warning messages - even if they don't specifically appear to be related to your committed code.

Anik Sengupta
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 3, 2025

Great Doug thanks for confirming that helps.

0 votes
Anik Sengupta
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 1, 2025

Hello Doug,

Welcome to Atlassian Community.

When Bamboo runs a Script task, the script is run by the host machine interpreter or shell, and the success of the script is determined by some factors such as;

The required executables or libraries for the script on the Agent environment or in the Docker container for a Job in an isolated build.
The exit code of the interpreter, a non-zero exit code is treated as an atypical exit and signals an error.
When Bamboo gets a non-zero exit code, it's interpreted as a failure, and this will cause the script task to fail, so it has to be clear if the non-zero is a true negative or a false negative.

Can you provide us with the complete build logs ?

Does the failure affect all remote agents?
What is the affected Agent OS and version?
What is the compiler SDK and version?
Was there any change to the remote agent or build SDK?
Can you confirm what change was introduced to the build which may be causing it to fail?
This may be the potential cause of the failure since a compile time failure can stop a build and return a none 0 exit code.


Regards,

Anik Sengupta

**please don't forget to Accept the answer if your query was answered**

Doug Gordon February 1, 2025

Hi Anik

 

Thanks for the welcome. My agency won't allow me to provide logs externally.  I am new to Bamboo, as you can probably tell from my question.

 

This is a new project where I have committed and pushed some SAS SQL code to my branch in my development repo in Bitbucket.  AFAIK all my agency's Bamboo requirements have been met, and a commit to our development Bitbucket auto generates a build to start.  This is managed by a 'deploy.yml' file that I have added my code reference to.

The code that I comitted builds SAS tables in our development data grid that are then migrated to our visualisation software for me to begin the development of a report there.  

 

I was hoping that there was a strightforward fix to resolve the SSH Command Failed as my deploy.tml file is almost identical to the main branch one - just with my code reference correctly added.  Everything else seems to work fine, there are no errors in the code that build the tables, and it only appears that the exit code is failing the job.


"Result: exit code = 2.
SSH command failed. Failing build."

I'm going to confirm with the system admins tomorrow if the failure is due to the location of my code, or if they have seen the error before.  

Cheers

 

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events