{"action":"created","issue":{"url":"https://api.github.com/repos/travis-ci/travis-ci/issues/879","labels_url":"https://api.github.com/repos/travis-ci/travis-ci/issues/879/labels{/name}","comments_url":"https://api.github.com/repos/travis-ci/travis-ci/issues/879/comments","events_url":"https://api.github.com/repos/travis-ci/travis-ci/issues/879/events","html_url":"https://github.com/travis-ci/travis-ci/issues/879","id":10318023,"number":879,"title":"Script that depends on branch","user":{"login":"betesh","id":2154282,"avatar_url":"https://avatars.githubusercontent.com/u/2154282?v=3","gravatar_id":"","url":"https://api.github.com/users/betesh","html_url":"https://github.com/betesh","followers_url":"https://api.github.com/users/betesh/followers","following_url":"https://api.github.com/users/betesh/following{/other_user}","gists_url":"https://api.github.com/users/betesh/gists{/gist_id}","starred_url":"https://api.github.com/users/betesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/betesh/subscriptions","organizations_url":"https://api.github.com/users/betesh/orgs","repos_url":"https://api.github.com/users/betesh/repos","events_url":"https://api.github.com/users/betesh/events{/privacy}","received_events_url":"https://api.github.com/users/betesh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2013-01-25T16:56:05Z","updated_at":"2015-02-19T17:40:39Z","closed_at":"2013-01-27T03:34:28Z","body":"I'm looking to do something like this in my .travis.yml file:\r\n\r\nbefore_script:\r\n  - 1.0-stable: \"cd test/dummy && rake db:schema:load\"\r\n  - 2.0-stable: \"cd spec/dummy && rake db:schema:load\"\r\nscript:\r\n  - 1.0-stable: \"bundle exec rake\"\r\n  - 2.0-stable: \"bundle exec rspec spec\"\r\n\r\nAlternatively, it could be:\r\n\r\nbranches:\r\n  - 1.0-stable: \r\n    - before_script: \"cd test/dummy && rake db:schema:load\"\r\n    -  script: \"bundle exec rake\"\r\n  - 2.0-stable: \"cd spec/dummy && rake db:schema:load\"\r\n    - before_script: \"cd spec/dummy && rake db:schema:load\"\r\n    - script: \"bundle exec rspec spec\"\r\n\r\nI know I could write my own bash script that does this and then use:\r\n\r\nscript: my_own_script.sh\r\n\r\nbut because the conditional logic involved is \"What branch am I on?\", I'd be duplicating functionality that travis is already doing when parsing the YML file.  I'd also have to have separate files for script, before_script and after_script, which would all use identical logic and vary only in what commands they run in each condition--basically, a lot of code duplication.\r\n\r\nIt's possible this feature already exists, but I can't find any docs on it.  So I humbly submit it as a feature request."},"comment":{"url":"https://api.github.com/repos/travis-ci/travis-ci/issues/comments/75098777","html_url":"https://github.com/travis-ci/travis-ci/issues/879#issuecomment-75098777","issue_url":"https://api.github.com/repos/travis-ci/travis-ci/issues/879","id":75098777,"user":{"login":"bennyn","id":469989,"avatar_url":"https://avatars.githubusercontent.com/u/469989?v=3","gravatar_id":"","url":"https://api.github.com/users/bennyn","html_url":"https://github.com/bennyn","followers_url":"https://api.github.com/users/bennyn/followers","following_url":"https://api.github.com/users/bennyn/following{/other_user}","gists_url":"https://api.github.com/users/bennyn/gists{/gist_id}","starred_url":"https://api.github.com/users/bennyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bennyn/subscriptions","organizations_url":"https://api.github.com/users/bennyn/orgs","repos_url":"https://api.github.com/users/bennyn/repos","events_url":"https://api.github.com/users/bennyn/events{/privacy}","received_events_url":"https://api.github.com/users/bennyn/received_events","type":"User","site_admin":false},"created_at":"2015-02-19T17:40:38Z","updated_at":"2015-02-19T17:40:38Z","body":"Hi guys, sorry for commenting this old isse but I tried to put my commands in an extra shell script which does:\r\n```bash\r\n#!/bin/sh\r\n\r\nif [ $TRAVIS_BRANCH == 'develop' ]; then\r\n  se-interpreter test/selenium/interpreter_config.json\r\nfi\r\n```\r\n\r\nIn my `.travis.yml` I put:\r\n\r\n```bash\r\nsudo: true\r\n\r\n...\r\n\r\nbefore_script:\r\n  - chmod +x before_script.sh\r\n  - ...\r\nscript: ./before_script.sh\r\n```\r\n\r\nBut Travis complains with:\r\n\r\n```bash\r\n$ ./before_script.sh\r\n./before_script.sh: 3: [: selenium-config: unexpected operator\r\nThe command \"./before_script.sh\" exited with 0.`\r\n```\r\n\r\nBefore I ran my Selenium tests with `script: \"se-interpreter test/selenium/interpreter_config.json\"`. \r\n\r\nSo can you tell me what's wrong there and how I can run my `\"se-interpreter test/selenium/interpreter_config.json\"` command only when building the `develop` branch?"}}