一,部署包转移方式java
1,jenkin插件环境配置git
进入Global Tool Configurationbash
配置java环境 maven环境网络
2, SSH插件安装app
插件安装之后须要从新启动(若是选择自动从新启动,再也不须要重启)ssh
启动之后从新进入 系统管理——>系统设置,maven
3,GIT代码拉取配置插件
进入 系统管理添加git 用户配置code
我采用的是public key方式,固然你能够使用用户名密码的方式ip
4,而后添加一个maven项目进行配置(新版的jenkins须要添加maven插件)
在项目工程中源码管理设置中配置上面设置的git用户
ssh文件传送配置
二:GIT脚本自动代码拉取+SHELL脚本自动部署(避免网络传送耗时)
与前者相比不须要SSH plugin 来传送文件。
在这里须要说明的是一个 git自动拉取代码的脚本文件,在此贴出来。
#!/bin/bash #T License (MIT) # Copyright (c) 2013 Alvin Abad if [ $# -eq 0 ]; then echo "Git wrapper script that can specify an ssh-key file Usage: git.sh -i ssh-key-file git-command " exit 1 fi # remove temporary file on exit trap 'rm -f /tmp/.git_ssh.$$' 0 if [ "$1" = "-i" ]; then SSH_KEY=$2; shift; shift echo "ssh -i $SSH_KEY \$@" > /tmp/.git_ssh.$$ chmod +x /tmp/.git_ssh.$$ export GIT_SSH=/tmp/.git_ssh.$$ fi # in case the git command is repeated [ "$1" = "git" ] && shift # Run the git command git "$@"
这种拉代码的方式为 git public key 的方式,须要指定key文件所在。