title: How to get Travis-CI build_number within after_script command
body: <p>How can one get the <em>build_number</em> (and other build metadata) from within the <code>after_script</code> command in Travis-CI?</p>
  
  <p>What have been tried already:</p>
  
  <p>The <a href="http://about.travis-ci.org/docs/user/build-configuration/" rel="noreferrer">documentation on build configuration</a> says this, in the <strong>IRC notification</strong> section:</p>
  
  <blockquote>
    <p>You also have the possibility to customize the message that will be
    sent to the channel(s) with a template:</p>
  
  <pre><code>notifications:
    irc:
      channels:
        - "irc.freenode.org#travis"
        - "irc.freenode.org#some-other-channel"
      template:
        - "%{repository} (%{commit}) : %{message} %{foo} "
        - "Build details: %{build_url}"
  </code></pre>
    
    <p>You can interpolate the following variables:</p>
    
    <ul>
    <li><em>repository</em>: your GitHub repo URL.</li>
    <li><em>build_number</em>: build number.</li>
    <li><em>branch</em>: branch build name.</li>
    <li><em>commit</em>: shorten commit SHA</li>
    <li><em>author</em>: commit author name.</li>
    <li><em>message</em>: travis message to the build.</li>
    <li><em>compare_url</em>: commit change view URL.</li>
    <li><em>build_url</em>: URL of the build detail.</li>
    </ul>
  </blockquote>
  
  <p>Trying to get this to work within an <code>after_script</code> command as below, did not work at all:</p>
  
  <pre><code>language: java
  after_script:
    - git commit -a -m "Committed by Travis-CI build number: %{build_number}"
  </code></pre>
  
  <p>It behaved as if <code>.travis.yml</code> file was absent/invalid (even though it did pass the Travis-CI YAML validation <a href="http://lint.travis-ci.org/" rel="noreferrer">here</a>).</p>
  
  <p>It seems as though this should be doable, but could not find any sample that does this.</p>
  
  <p>Could someone point me in the right direction?</p>