nohup java -jar jenkins.war --httpPort=8888 >> ~/ci/jenkins.log 2>&1 &
可訪問外網用在線方式:系統管理->管理插件->可選插件->安裝SSH plugin
內網用離線方式:下載 ssh.hpi http://updates.jenkins-ci.org/latest/ssh.hpi ,更名爲ssh.jpi,放入$JENKINS_HOME/plugins/ java
ssh-keygen -t rsa #生成公私鑰對 ~/.ssh/id_rsa, ~/.ssh/id_rsa.pub
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys #chmod 600 ~/.ssh/id_rsa
rm ~/.ssh/id_rsa.pub
clean install -Pdev -DskipTests=true
scp ~/.m2/repository/com/demo/gateway/1.0.0/gateway-1.0.0.war app@172.17.140.11:/home/app/gateway.war
home_path=/home/app server_path=$home_path/servers/jboss deploy_path=$server_path/standalone/deployments cd $deploy_path rm -rf gateway.war mkdir gateway.war cd gateway.war cp $home_path/gateway.war ./ $JAVA_HOME/bin/jar xvf gateway.war rm gateway.war nohup $server_path/bin/xxx.sh stop > /dev/null 2>&1 & sleep 5 nohup $server_path/bin/xxx.sh start > /dev/null 2>&1 &
如今,只要在jenkins上執行job就能進行自動部署了 shell