- Recommended hardware configuration for a small team:
- 1 GB+ of RAM
- 50 GB+ of drive space
-
Refer to the following link: https://jenkins.io/doc/book/installing/
- Debian/Ubuntu:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
-
When Jenkins is installed, it's now at localhost:8080.
- Create a admin user for Jenkins
- Click on New Item button or create new job, name the item <app-name> and select Build a free-style software project option and click the OK button.
- Add Build Step: Click on Add Build Step button and select Execute Shell option. Enter the the command you want to execute. Example:
ssh -tt your-name@ip-server <<EOF
sudo -s
cd
git pull
npm install
pm2 restart all
exit
exit
EOF
- On server Jenkins, create a SSH key with user Jenkins
sudo -u jenkins bash
ssh-keygen -t rsa -C "your_email@example.com"
- Configure your created SSH in production server
- You also need to configure SSH key for your repository in Github, Gitlab, Bitbucket,... similarly.
- Now when you want to build, you only need to click Build now.
- You can configure more plugin like Bitbucket Plugin and webhook for auto deployment, following this link: "https://medium.com/@mohan08p/jenkins-integration-with-bitbucket-github-webhook-25a191507cab"