Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8067801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:27:02+00:00 2026-06-05T12:27:02+00:00

I have a development branch hosted on Heroku and we have a couple of

  • 0

I have a development branch hosted on Heroku and we have a couple of people using this branch to look for bugs, it would be nice to show the SHA-1 Hash of the commit that’s the latest deployed on Heroku so that we know which bugs belong to which commit.

But I cannot at all find any way to find this information. nothing in the ENV variable in heroku run console. Though “heroku releases” does show a list of deployment info, including the first few character of the SHA-1 hash, that leads me to think that Heroku must store it somehwere, but I just cannot find where. Does anyone know?

I realize that I haven’t really put down the question as clear as I should: I meant to find the SHA-1 hash inside Rails on Heroku. Like I can do something like this:

<h1><%= ENV['REV']</h1>

Thank You!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:27:05+00:00Added an answer on June 5, 2026 at 12:27 pm

    Treat Heroku just like any other remote Git repo – you can use git ls-remote:

    git ls-remote heroku

    (heroku here being the remote name)

    UPDATE:

    Since the OP is actually looking to acquire the SHA in the Ruby env, one possible way would be to use a custom buildpack.

    To get started, head over to Heroku’s Ruby Buildpack and fork it so you can make your own variations. Now clone your fork and take a look at lib/language_pack/ruby.rb. Add a new method, something like:

    def get_SHA
        #get SHA
        #save SHA to ENV, ala: ENV['SHA'] = retrieved_sha
    end
    

    How you go about getting the SHA is up to you. You could execute a git command and use what’s returned:

    git log -1 --format="%H"

    Or you could use @avaynshtok’s advice and use the Heroku gem to use the releases method.

    Then, once you have the SHA, set it as an ENV var.

    Next, find the compile method in ruby.rb, and add the get_sha method to the end of it:

    def compile
        Dir.chdir(build_path)
        install_ruby
        setup_language_pack_environment
        allow_git do
            install_language_pack_gems
            build_bundler
            create_database_yml
            install_binaries
            run_assets_precompile_rake_task
            get_sha #your additional method
        end
    end
    

    Push your changes back up to GitHub, and now head over to the command line. You’ll need to add a new config var to your Heroku app:

    heroku config:add BUILDPACK_URL=git@github.com:<your GitHub username>/heroku-buildpack-ruby.git

    Note that you’ll need to make sure you’ve replace <your GitHub username> with…well, your GitHub username, so you are pointing at your forked repo.

    Finally, execute one last command that enables a Heroku labs feature that allows the slug compiler access to user vars:

    heroku labs:enable user_env_compile

    Now you should be all set. So what exactly happens now? Well, when you push to Heroku, Heroku will receive the changes, and then see that you have a custom buildpack url set. So it’ll fetch your custom buildpack from GitHub, and then use that to create the slug. That means that once it runs through all of the default compile commands, it’ll end with your get_sha method, which should set the ENV var SHA to the appropriate SHA. Now you should have access to that ENV var from within Ruby, to do with what you will.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Previously, using SVN, I would have a branch that was my development branch, which
Using TFS, we have the following: A main baseline A development branch for each
A common scenario when using source control is to have a development branch along
I have imported my svn repository to git. My current branch for development is
we have a mixed development environment using ASP.NET MVC and Ruby on Rails. We
I have a master and development branch . I did some commits to the
Alright, I have a development branch that is tracked remotely and shared by everyone
I have this problem where I'm merging changes up into my integration branch but
In our team we are using a development, staging and a master branch plus
I'd like to have a git repository with a branch for development and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.