# 依赖:
sudo yum install -y curl policycoreutils-python openssh-server
#启动ssh服务&设置为开机启动
sudo systemctl enable sshd
sudo systemctl start sshd
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
# 下载
sudo yum install -y gitlab-ce
# 出现图标表示成功
#修改 /etc/gitlab/gitlab.rb文件
vi /etc/gitlab/gitlab.rb
# 默认的站点Url配置项
external_url 'http://gitlab.example.com'
# 默认的端口是80,修改默认端口
nginx['listen_port'] = 91
#从新配置并启动
sudo gitlab-ctl reconfigure
复制代码
#从旧址clone下来
git clone --bare gitlab@github.news.com/groups:test.com.git
# push到新址
git push --mirror gitlab@github.xx.com:newgroups/newtest.com.git
# 将本地的url修改成新的url
git remote set-url origin gitlab@github.xx.com:newgroups/newtest.com.git
复制代码
https://cloud.tencent.com/developer/article/1333790
http://www.luyixian.cn/news_show_9166.aspx
复制代码
# 官网下载
https://www.sonatype.com/download-oss-sonatype
nexus-3.13.0-01-unix.tar.gz
# 解压
tar -zxvf apache-maven-3.5.2-bin.tar.gz
mv nexus-3.6.0-02 /usr/local/
cd /usr/local/nexus-3.6.0-0.2/bin
# 启动
./nexus start
复制代码
已-SNAPSHOT结尾的jar,不能经过页面上传,须要在项目pom文件配置,或手动上传,这里由于没有源码,只有jar手动上传。java
# 修改并运行命令,
mvn deploy:deploy-file
-DgroupId=com.ucf.um
-DartifactId=visa
-Dversion=1.0.12-SNAPSHOT
-Dpackaging=jar
-Dfile=C:/Users/chenyd/Desktop/visa/visa/1.0.12-SNAPSHOT/visa-1.0.12-SNAPSHOT.jar
-Durl=http://172.20.0.10:8081/repository/Ihhb_snapshot/
-DrepositoryId=maven-snapshot
# 解释
Durl须要是SNAPSHOT仓库,
DrepositoryId是setting文件中配置的帐号ID
复制代码
***注意python
***下载不下来快照nginx
***包都有,项目正常启动,可是idea maven project 报错git
<!--
maven配置文件
-->
<settings>
<!-- 发布到私服 -->
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>maven-public</id>
<mirrorOf>*</mirrorOf>
<url>http://172.20.0.10:8081/repository/maven-public/</url>
</mirror>
<mirror>
<!--This sends everything else to /public -->
<id>maven-snapshot</id>
<mirrorOf>Ihhb_snapshot</mirrorOf>
<url>http://172.20.0.10:8081/repository/Ihhb_snapshot/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>development</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<!--this profile will allow snapshots to be searched when activated-->
<id>Ihhb_snapshot</id>
<repositories>
<repository>
<id>Ihhb_snapshot</id>
<url>http://Ihhb_snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>Ihhb_snapshot</id>
<url>http://Ihhb_snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>Ihhb_snapshot</activeProfile>
</activeProfiles>
<localRepository>/data/apache-maven-3.6.1/maven_repository</localRepository>
<!-- 发布的服务器和密码,暂时未限制权限,请不要提交不稳定版本 -->
<servers>
<server>
<id>maven-public</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>maven-snapshot</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
</settings>
复制代码
# 官网下载
https://jenkins.io/download/
# 能够tomcat启动,也可直接启动,修改端口
java -jar jenkins.war --ajp13Port=-1 --httpPort=8090
# 访问采用新手安装
复制代码
安装插件github
发布插件 Deploy to container Plugin 必须
Maven插件 Maven Integration plugin必须
git插件 Git plugin
如须要git根据target部署,须要Dynamic Parameter Plug-in 插件,这个插件下载不了,CSDN收费,这里提供免费网盘
连接:https://pan.baidu.com/s/1hvl_URW8s1mvLIRv1jFhUg
提取码:rnw7
复制代码
系统设置修改apache
SSH登录配置
# 登录服务器生成密钥
ssh-keygen
# 发送公钥到须要目标服务器上
ssh-copy-id -i /root/.ssh/id_rsa.pub root@目标服务器主机ip
# 登录
ssh root@目标服务器主机ip
复制代码
全局工具配置修改tomcat
修改setting bash
构建maven项目服务器
保留2次构建的记录app
获取git源码
服务器生成的密钥对,私钥用于gitlab文件建立
公钥用于添加凭证
maven打包跳过测试,选择编译的环境
编译后执行的脚本
目标服务器上的脚本
不知道什么缘由,Jenkins构建好的包没有上传到远端服务器,因此写脚本传输,启动。
echo "切换到项目地址"
cd /apps/product/exch
echo "关闭exch-platform.jar进程"
ps -ef|grep java|grep exch-platform.jar|awk '{print $2}'|xargs kill -9
echo "删除包"
rm -rf exch-platform.jar
echo "传包"
scp root@172.20.0.10:/root/.jenkins/workspace/exch-test-0.13/exch_platform/target/exch-platform.jar /apps/product/exch
echo "启动"
/apps/product/jdk1.8.0_181-amd64/bin/java -jar exch-platform.jar > nohup.out &
echo "完成"
复制代码
***注意
没有自动传包到远端服务器的缘由,是由于我只关注了,构建后登录的地址是在配置SSH登录服务器的路径之上。没有关注,打包好的文件路径,是工做空间的相对路径。修改文件的路径和前缀后自动传包成功。