标签:ati project hub ssl pos ping lis tle evel
================================================================================
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 [setting] - [webhook]
#3. Click [Add webhook]
Title: CI Notification
URL: http://jenkins_server_ip:8080/bitbutket-hook/
status: Active
SSL / TLS [unchecked]
Triggers: choose [Repository push]
+++++++++++++++++++++++ helloworld_build_app +++++++++++++++++++++++
#1. Click "New Item" at the top right.
#2. Enter an item name. [helloworld_build_app]
#3. Select Freestyle project option.
#4. Click "OK" button.
#5. Typing your_display_name [helloworld_build_app] 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 [select this option only you install bitbucket plugin]
#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. [helloworld_deploy_app]
#3. Select Freestyle project option.
#4. Click "OK" button.
#5. Typing your_display_name [helloworld_deploy_app] 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 [helloworld_build_app]
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 ]
================================================================================
continous integration environment (Jenkins and bitbucket configuration)
标签:ati project hub ssl pos ping lis tle evel
原文地址:http://www.cnblogs.com/stavenVanderbilt/p/7782886.html