Environmental centos7
A, gogs installation --- here using git user, I was actually installed in / usr / local / gogs with the root
1, adding users, setting sudo, see the kernel version information to confirm architecture, download the appropriate installation package
useradd
git #添加用户
vim /etc/sudoer
No password is required ALL # add this line to perform sudo: git ALL = (ALL) NOPASSWD
The files can not be edited to change the read-only permission to write chmod u + w / etc / sudoer # changed back chmod uw / etc / sudoer
uname
-a #查看内核架构版本
wget https://dl.gogs.io/0.11.91/gogs_0.11.91_linux_amd64.tar.gz # downloading the installation package corresponding to the binary
2, unzip the package to git directory, and modify permissions and owner, installed base environment, start gogs
tar -xf gogs_0.11.91_linux_amd64.tar.gz -C / home / git /
chmod -R 755 /home/git/gogs
chown -R git:git /home/git/gogs
yum -y install git nginx
su - git -c "cd /home/git/gogs && ./gogs web &"
3, add startup items
cp scripts/systemd/gogs.service /etc/systemd/system
cp scripts/init/centos/gogs /etc/init.d/
chmod u+x scripts/init/centos/gogs
chmod u+x scripts/systemd/gogs.service
ln -sf scripts/systemd/gogs.service /usr/lib/systemd/
systemctl enable gogs.service
systemctl status gogs.service
#如不行 chkconfig gogs on && service gogs restart
4, set idea, submitted by the project code
4.1, the menu VCS --- Enable Version Control Integration --- git
4.2, set the remote address: Right-click on the project select menu Git -> Repository -> Remotes
4.3, Git add-> commit-> push, then refresh the page gogs
Two, gogs set with jenkins
1, gogs public warehouse setting and adding jenkins
1.1 Login Manager account, click an item, select the warehouse setting
1.2 Adding web hook, designated jenkins project address, format: http (s):? // <your Jenkins address> / gogs-webhook / job = <your name Jenkins task>
1.3 User Settings --SSH top right corner of the key, the public key is added jenkins
2, jenkins install plug-ins, and set up new projects and build git address, triggers, etc.
2.1, install the plug-in, set the environment and new projects set up warehouse address
Plug:
Publish Over SSH
Gogs plugin
Deploy to container
Build Authorization Token Root Plugin
#jenkins ---系统管理---全局工具配置
###新建一个maven项目,设置git仓库地址,并且使用jenkins本身的私钥进行验证
####选择对应自己想要的触发器
3、tomcat设置管理帐户
192.168.10.227 tomcat2
vim /usr/local/tomcat2/conf/tomcat-users.xml
#添加以下配置
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="password" roles="admin-gui,admin,manager-gui,manager,manager-script,manager-jmx,manager-status"/>
$vim /usr/local/tomcat2/conf/Catalina/localhost
<Context privileged="true" antiResourceLocking="false"
docBase="${catalina.home}/webapps/manager">
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
</Context>
4、设置jenkins构建后操作,自动部署war到tomcat
三、测试远程触发自动构建war,并且发布
1、访问 http://192.168.10.79:8080/job/etoppay-cron/build?token=123456 格式参考设置令牌提示
2、可以看到已经自动构建成一个war,一个jar包,并且自动发布