Skip to content

Instantly share code, notes, and snippets.

@rsanheim
Created March 28, 2012 05:03

Revisions

  1. rsanheim revised this gist Apr 2, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions ci.sh
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@
    # * You want to deploy all branches.
    # * You wired up an SSH key to your CI server appropriately so it can talk to your deployment target(s) via Cap

    set -e
    script/test # or bundle exec rake, or whatever

    echo "Beginning deploy from $GIT_BRANCH...."
  2. rsanheim revised this gist Mar 28, 2012. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions ci.sh
    Original file line number Diff line number Diff line change
    @@ -10,9 +10,7 @@

    script/test # or bundle exec rake, or whatever

    echo
    echo "Beginning deploy from $GIT_BRANCH...."
    echo
    # Do some git clean up and checkout and pull a branch
    # Jenkins by default will be in a detached HEAD state, which Capistrano doesn't like
    git remote prune origin
  3. rsanheim revised this gist Mar 28, 2012. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions ci.sh
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,14 @@
    #!/bin/bash -x

    # This should be your "script/ci" checked into version control, and then wired as your sole build step in Jenkins.
    # Note that this assumes you build all branches, and want to deploy all branches.
    #
    # Simplifying Assumptions:
    #
    # * You build all branches
    # * You want to deploy all branches.
    # * You wired up an SSH key to your CI server appropriately so it can talk to your deployment target(s) via Cap

    # standard build stuff here
    # bundle, rake, script/test or whatever
    script/test # or bundle exec rake, or whatever

    echo
    echo "Beginning deploy from $GIT_BRANCH...."
  4. rsanheim revised this gist Mar 28, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions ci.sh
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,8 @@
    echo
    echo "Beginning deploy from $GIT_BRANCH...."
    echo
    # Do some git clean up and checkout and pull a branch
    # Jenkins by default will be in a detached HEAD state, which Capistrano doesn't like
    git remote prune origin
    git fetch origin
    git branch -t -f local/$GIT_BRANCH $GIT_BRANCH
  5. rsanheim revised this gist Mar 28, 2012. 2 changed files with 6 additions and 1 deletion.
    2 changes: 1 addition & 1 deletion ci.sh
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,4 @@ git fetch origin
    git branch -t -f local/$GIT_BRANCH $GIT_BRANCH
    git checkout local/$GIT_BRANCH
    git pull
    bundle exec cap staging deploy
    bundle exec cap deploy
    5 changes: 5 additions & 0 deletions deploy.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # ...meanwhile, in your Capistrano config somewhere:

    # configure your deployments to always go from the current branch
    set(:current_branch) { `git branch`.match(/\* (\S+)\s/m)[1] || raise("Couldn't determine current branch") }
    set :branch, defer { current_branch }
  6. rsanheim revised this gist Mar 28, 2012. No changes.
  7. rsanheim revised this gist Mar 28, 2012. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions ci.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    #!/bin/bash -x

    # This should be your "script/ci" checked into version control, and then wired as your sole build step in Jenkins.
    # Note that this assumes you build all branches, and want to deploy all branches.

    # standard build stuff here
    # bundle, rake, script/test or whatever

  8. rsanheim renamed this gist Mar 28, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. rsanheim revised this gist Mar 28, 2012. 2 changed files with 0 additions and 14 deletions.
    File renamed without changes.
    14 changes: 0 additions & 14 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,14 +0,0 @@
    #!/bin/bash -x

    # standard build stuff here
    # bundle, rake, script/test or whatever

    echo
    echo "Beginning deploy from $GIT_BRANCH...."
    echo
    git remote prune origin
    git fetch origin
    git branch -t -f local/$GIT_BRANCH $GIT_BRANCH
    git checkout local/$GIT_BRANCH
    git pull
    bundle exec cap staging deploy
  10. rsanheim revised this gist Mar 28, 2012. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions ci.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/bin/bash -x

    # standard build stuff here
    # bundle, rake, script/test or whatever

    echo
    echo "Beginning deploy from $GIT_BRANCH...."
    echo
    git remote prune origin
    git fetch origin
    git branch -t -f local/$GIT_BRANCH $GIT_BRANCH
    git checkout local/$GIT_BRANCH
    git pull
    bundle exec cap staging deploy
  11. rsanheim created this gist Mar 28, 2012.
    14 changes: 14 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/bin/bash -x

    # standard build stuff here
    # bundle, rake, script/test or whatever

    echo
    echo "Beginning deploy from $GIT_BRANCH...."
    echo
    git remote prune origin
    git fetch origin
    git branch -t -f local/$GIT_BRANCH $GIT_BRANCH
    git checkout local/$GIT_BRANCH
    git pull
    bundle exec cap staging deploy