continous integration environment (Jenkins and bitbucket configuration)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 [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://[email protected]/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 [email protected]

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://[email protected]/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 [email protected]
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)的主要内容,如果未能解决你的问题,请参考以下文章

GitHub+Jenkins持续集成简介

PHP国家代码到大陆

UVa 11094 - Continents

Java技术_Java千百问(0020)_break与contine分别如何使用

2019 ICPC Asia-East Continent Final

contine 和break 的区别