First of all, thanks to carbonsilk for providing the first tutorial on how to configure automated deployment with Git and Jenkins.
But things have changed since 2011 so I’d like to share my simplified setup on automated (continuous) deployment of node.js applications with forever, git and jenkins. I’m using BitBucket in the example, you can just exchange the hostname with github.com for github repositories.
- As root/sudo:
sudo apt-get install jenkins
(open port 8080 in your firewall)
sudo npm install -g express connect karma forever
- As user 'jenkins' (sudo su jenkins)
git config --global user.name 'Jenkins' git config --global user.email 'firstname.lastname@example.org' ssh bitbucket.org -l git (add the server to the list of authorised hosts) ssh-keygen -t rsa && cat ~/.ssh/id_rsa.pub
- Jenkins Web (http://yourserver:8080)
- Manage Jenkins - Manage Plugins - Search 'Git' - Install GIT plugin
- Manage Jenkins - Configure System - Enable security - Jenkins's own user database (Allow signup) - Logged-in users can do anything
- Register your user (remove Allow signup afterwards in the config)
- Add Job - 'Build a free-style software project'
- Source Code Management: Git (Repository URL: email@example.com:team/project.git)
- 'Check Trigger builds remotely' (e.g., from scripts) and add random long password.
- Execude Shell:
npm install npm update forever stopall BUILD_ID=dontKillMe NODE_ENV=production forever start app.js
- Go to Git provider (BitBucket, GitHub) and add Jenkins Service.