title: Defining secure environment variables for multiple repositories in a single .travis.yml
body: <p>I am working on a project that is using Travis CI. Some of our tests require secure credentials to be defined in environment variables, or else they are skipped. We are using <a href="http://docs.travis-ci.com/user/encryption-keys/">the <code>encrypt</code> command of the Travis CLI gem</a> to define a <a href="http://docs.travis-ci.com/user/build-configuration/#Secure-environment-variables">secure environment variable</a> for our primary repository, <code>owner/Project</code>. This variable is included in our <code>.travis.yml</code> file as follows:</p>
  
  <strong>Single-Repository Configuration</strong>
  
  <pre class="lang-yaml prettyprint-override"><code>env:
    secure: "av9hxTZp/Dhe9xAOq6WlhTNDoWjjczN3lFanG6h/3h4kW7DsxhfXMRA96z6MambbC6c9ARFiwsQ24NeCAfPQ1m6r9uZwNkusqnRDOwZQeVQcmopnoNNG4Kd/9oclIVgsAlSG6WfhkyQPUG2p7PkOvxFV4/YjDSViYDR3eoih3JA="
  </code></pre>
  
  <p><code>travis encrypt</code> has encrypted these variables using the private key for our <code>owner/Project</code>, and Travis runs the credentialed tests successfully for that repository.</p>
  
  <p>However we have another repository, <code>contributor/Project</code>, which is also used for development. When Travis is run in that repository, the secure environment variables are not available, and the credentialed tests are skipped.</p>
  
  <p>I used <code>travis encrypt</code> to encrypt a set of credentials for <code>contributor/Project</code>, and tried to add it to the <code>.travis.yml</code> like this:</p>
  
  <strong>Causes Extra Builds</strong>
  
  <pre class="lang-yaml prettyprint-override"><code>env:
    - secure: "av9hxTZp/Dhe9xAOq6WlhTNDoWjjczN3lFanG6h/3h4kW7DsxhfXMRA96z6MambbC6c9ARFiwsQ24NeCAfPQ1m6r9uZwNkusqnRDOwZQeVQcmopnoNNG4Kd/9oclIVgsAlSG6WfhkyQPUG2p7PkOvxFV4/YjDSViYDR3eoih3JA="
    - secure: "TcOCPDytGQpQgiP4w4LRdLXn+pUvhf5SjJF4J3TXjaPUCfomNfod2WTZn3v4WBR2kg3UCaeqFo2BmGUdwCdPbrAZ3cF2W749HLNU0Z2zxFWru5W+GAGgUi2FXIzzjF+U8Hb/2fLZ6GoUiSlNzVHKo/+kvLDAyuGnGFwfH7dpEb8="
  </code></pre>
  
  <p>This resulted in Travis running two different versions of the build. One attempted to use each set of secure credentials. Since only one set was valid for a given repository, this would result in the test suite being run twice, once with credentials and once without. <a href="https://travis-ci.org/jeremybanks/ChatExchange/builds/24043847">You can see an example build here</a>.</p>
  
  <p>This extra build is wasteful and unnecessary. If the test is running in an environment where neither set of secure credentials are available (such as a pull request from a fork), the test suite will be run without credentials twice. Adding more sets of credentials would be even worse; you'd have several redundant uncredentialed builds for every credentialed build.</p>
  
  <p>How can I define secure environment variables for multiple repositories in a single Travis configuration without causing extra builds to occur?</p>