1.工具的安裝:git
1.1.安裝gitlab,具體過程省略web
1.2.安裝nexus,具體過程省略shell
1.3.安裝jenkins:api
http://www.javashuo.com/article/p-csgjvxrl-go.html服務器
1.4.ansible 安裝和使用(一種運維的腳本):app
http://www.javashuo.com/article/p-psqczhkc-ee.html運維
1.5.安裝git,具體過程省略curl
1.6.安裝mavenmaven
2.jenkins配置:工具
2.1.插件安裝配置:
2.1.1.第一次進入系統時,安裝默認提示的插件
2.1.2.進入:系統管理->管理插件,安裝:
Maven Integration plugin
Publish Over SSH
SSH plugin
Git Parameter Plug-In
2.2.進入:系統管理->Global Tool Configuration,配置:
maven
git
jdk
2.3配置訪問git的私鑰 Credentials -> System -> Global credentials (unrestricted)
2.4.配置SSH remote hosts,用於登陸服務器執行shell命令,系統管理->系統設置
2.5.創建job
clean deploy -pl api -DaltDeploymentRepository=nexus-snapshots::default::http://****/nexus/content/repositories/snapshots/ -U
curl -v --user 'admin:admin123' --upload-file $WORKSPACE/web_app/target/web_app.war "http://***/nexus/content/repositories/snapshots/com/fuxg/my_ci_demo/my_ci_demo.war"
set +x
cd /opt/ansible_playbook_dev/my_ci_demo
git fetch --all
git reset --hard origin/master
git pull
sudo ansible-playbook -i ./inventory/dev ./deploy.yml
set -x
3.ansible腳本的配置: