Archive for category git

Fresh machine installation notes for ruby developer

Ubuntu

  • System Settings –> Privacy : disable “include online search results”
  • Run command as a login shell
  • Terminal : unlimited scroll buffer

Git !

Install and configure git

sudo apt-get install git
git config --global user.name "My Name"
git config --global user.email "myemail@company.com"
git config --global --add color.ui true
git config --global push.default simple

I’m a big fan of this customized git prompt, only drawback a carriage return by default at the prompt-end. Just need to modify it in the .bash_profile

export GIT_PROMPT_END=' > '
source ~/.bash-git-prompt/gitprompt.sh

If needed regenerate a new github ssh key (discard your old keys on github and other server authorized_keys)

SublimeText

Raw sublime text installation via apt-get.
Install the package manager with this

Then install these packages :
– git gutter :

– rubyTest

sublimelinter : highlights lines of code the linter deems to contain (potential) errors.
BeautifyRuby : reformat your ruby code on demand (sometimes messy, but best I found)
Coffeescript : syntax highlighting
puppet : highlight, lint, snippet,…
and a few others 😉

Fix tabs and trailing issue before they appear

{
  "font_size": 11.0,
  "tab_size": 2,
  "translate_tabs_to_spaces": true,
  "trim_trailing_white_space_on_save": true,
  "ensure_newline_at_eof_on_save": true,
  "rulers":
	[
		95
	],
  "hot_exit": false,
  "remember_open_files": false
}

Have you ever wondered to turn a branch name “feature/my-awesome-feature-123” into a pre-filled commit message “My awesome feature #123”
Then gitils is for you. Last but not least, easy web page/sublime text integration with subl-handler. Thanks @toch !

Firefox

Ruby

rvm

sudo apt-get install curl
curl -L https://get.rvm.io | bash
source ~/.profile
rvm install ruby

I’m not a big fan, so I disable .rvmrc

I’m not often looking at ri or rdoc (most of the time I’m looking at the code directly) so I tweak ~/.gemrc to avoid downloading these artefacts.

gem: --no-ri --no-rdoc

native gem dependencies

Icu for charlockholmes, Postgresql for pg gem, and a running redis.

sudo apt-get install libicu-dev
sudo aptitude install libpq-dev
sudo apt-get install redis-server
cp /opt/redis/redis.conf.default /opt/redis/redis.conf

Devops

virtualbox

sudo apt-get install build-essential linux-headers-generic dkms
sudo apt-get install virtualbox

Vagrant

http://downloads.vagrantup.com/

wget http://files.vagrantup.com/packages/db8e7a9c79b23264da129f55cf8569167fc22415/vagrant_1.3.3_x86_64.deb
sudo dpkg -i vagrant_1.3.3_x86_64.deb
rm vagrant_1.3.3_x86_64.deb

veewee

rvm use 2.0.0@veewee --create
sudo apt-get install libxslt1-dev libxml2-dev zlib1g-dev
git clone https://github.com/jedi4ever/veewee.git
cd veewee
bundle install

packer ?

Skype

sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
sudo apt-get update
sudo apt-get install skype

Now what ?

Find a boxen equivalent for ubuntu and automate this… time to give a try to kitchenplan or take a look at thoughtbot script (not exactly in my stack, less sexy)

Advertisements

Leave a comment

Improved jenkins-github navigation

At work, we are using git feature branches extensively, we have a jenkins job configured to build all appearing branches origin/feature/* but it’s hard to know which commit/branch is linked to the build. So I will show you how we use the Groovy Postbuild Plugin to add github link and the branch that was built.

+ +
= cheap and useful navigation links

Continuous build

Add a groovy post build action :

def matcher = manager.getLogMatcher(".*Commencing build of Revision (.*) (.*)\$")
if(matcher?.matches()) {
    branch = matcher.group(2).substring(8,matcher.group(2).length()-1)
    commit = matcher.group(1).substring(0,6)
    githuburl = manager.build.getParent().getProperty("com.coravy.hudson.plugins.github.GithubProjectProperty").getProjectUrl().commitId(matcher.group(1))
    description = "<a href='${githuburl}'>${commit}</a>"+" - "+branch 
    manager.build.setDescription(description)
}

It assumes that you have configured the GitHub project url in the job configuration page from the github plugin.

Don’t forget to install the Extra columns plugin and configure your main view to display the build description.

github-build-descriptions

Deployment pipeline

For deployment job, inspired by GitHub, let’s say that you have an url on your website returning the current sha like /site/sha. You have a jenkins job that tracks commit on origin/develop and trigger a deployment.

Let’s add a shell script step in your job :

DEPLOYED_SHA="`wget --no-check-certificate -qO- https://github.com/site/sha`" 
echo CURRENTLY_DEPLOYED_SHA $DEPLOYED_SHA

Than postbuild groovy script that will show the deployed sha and the github difference between the previously deployed version :

def matcher = manager.getLogMatcher(".*commit (.*)\$")
if(matcher?.matches()) {
    branch = 'develop'
    commit = matcher.group(1).substring(0,6)
    projectUrl = manager.build.getParent().getProperty("com.coravy.hudson.plugins.github.GithubProjectProperty").getProjectUrl()
    githuburl = projectUrl.commitId(matcher.group(1))
    def matcher_currently_depoyed = manager.getLogMatcher(".*CURRENTLY_DEPLOYED_SHA (.*)\$")
    commit_from = matcher_currently_depoyed.group(1).substring(0,6)
    description = "<a href='${githuburl}'>${commit}</a> - ${branch} - <a href='${projectUrl.baseUrl}compare/${commit_from}...${commit}'>diff</a>"
    manager.build.setDescription(description)
}

Where the diff links gives you something like diff.

If you have other hack around GitHub and jenkins, keep me posted !

, ,

Leave a comment