continous integration environment (Jenkins and bitbucket configuration)
================================================================================continous integration environment (Jenkins and bitbucket configuration)
================================================================================
+++++++++++ install plugin on the jenkins website +++++++++++++
- jenkins plugin need to install:
ssh plugin, git plugin and bitbucket plugin
- add the public key [ jenkins server ] into bitbucket or github
you need to know which user run the jenkins service
cat ~/.ssh/id_rsa.pub
+++++++++++++++++++ configure bitbucket webhook ++++++++++++++++++++
#1. Click your project's repository
#2. Click -
#3. Click
Title: CI Notification
URL: http://jenkins_server_ip:8080/bitbutket-hook/
status: Active
SSL / TLS
Triggers: choose
+++++++++++++++++++++++ helloworld_build_app +++++++++++++++++++++++
#1. Click "New Item" at the top right.
#2. Enter an item name.
#3. Select Freestyle project option.
#4. Click "OK" button.
#5. Typing your_display_name on the field of Display Name after you click the Advanced button.
#6. Source Code Management
1) choose git
2)Repository URL: https://XXXX@bitbucket.org/XXXXXX/helloworld.git
3)Credentials: add into your credentails
#7. Build Triggers
Build when a change is pushed to BitBucket
#8. Build
===================================
Add Build Step => Execute Shell
===================================
#!/bin/bash --login
#exec 1> /tmp/jenkins_helloworld_build_app.log
echo "===============START TO BUILD=================="
export RAILS_ENV=test
#export $BUILD_NUMBER
echo "=============================================================="
whoami
echo $BUILD_NUMBER
echo "=============================================================="
source ~/.bashrc # Loads RVM
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
cd . # Loads the RVM environment set in the .rvmrc file
rvm current # will display current rvm (debugging purpoyse)
rvm -v
rvm list
rvm gemset list
rvm use 2.3.1@helloworld
rvm gemset list
RAILS_ENV=test bundle install --without development
RAILS_ENV=test bundle exec rails db:drop db:create db:migrate
RAILS_ENV=test bundle exec rails test
echo "=============== END TO BUILD =================="
================================================================================
+++++++++++++++++++++++ helloworld_deploy_app ++++++++++++++++++++++
#1. Click "New Item" at the top right.
#2. Enter an item name.
#3. Select Freestyle project option.
#4. Click "OK" button.
#5. Typing your_display_name on the field of Display Name after you click the Advanced button.
#6. Source Code Management
1) choose git
2)Repository URL: https://XXXXX@bitbucket.org/XXXXX/helloworld.git
3)Credentials: add into your credentails
#7. Build Triggers
1) Select Build after other projects are built
2) Projects to watch
3) Trigger only if build is stable
#8. Build
=================
Execute Shell
=================
#!/bin/bash --login
echo "===================== START TO DEPLOY ======================="
source ~/.bashrc # Loads RVM
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
cd . # Loads the RVM environment set in the .rvmrc file
rvm current # will display current rvm (debugging purpoyse)
rvm -v
rvm list
rvm gemset list
rvm use 2.3.1@helloworld
rvm gemset list
bundle exec cap staging puma:kill_puma
bundle exec cap staging deploy
echo "====================== END TO DEPLOY ======================="
cd /var/lib/jenkins/workspace/your_project_name
whomai=> jenkins
try to deploy your project via [ bundle exec cap staging deploy ]
================================================================================
页:
[1]