How can you determine if you managed to execute a command through the cli hero?

When starting a team through a hero, for example:

heroku run rake db:migrate 

I would like to know if the team succeeded or not. Unfortunately, even if the migration fails, I get exit status 0.

I am writing a ruby โ€‹โ€‹code that wraps this command and calls it, and causes an error if the command fails. The code looks like this:

 Open3.popen2e('heroku run rake db:migrate') do |stdin, stdout_and_stderr, wait_thr| raise 'running migration failed' unless wait_thr.value.success? end 

Even with this failure, I get a message:

rake is interrupted! StandardError: an error occurred, this and all later migrations are canceled:

My code alone does not cause an error. By checking wait_thr.value in the code above, it has an exit code of 0, which means that the heroโ€™s CLI believes that the rake call succeeded.

How can my code know if the team launched by the cli heroic worked? Is there any way to tell the CLI hero to return the status code of the team in which he was running?

+7
heroku heroku-toolbelt
source share
2 answers

Currently, official support for this from the CLI is:

 heroku help run Usage: heroku run COMMAND run an attached dyno -s, --size SIZE # specify dyno size --exit-code # return exit code from process 

So you now run:

  heroku run --exit-code rake db:migrate 
+7
source share

You are not alone with this. Many have complained about this before, check this out:
https://github.com/heroku/heroku/issues/186

You can (dirty) handle the problem with this stone:
https://github.com/glenngillen/heroku-exit-status

0
source share

All Articles