# 依賴:
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
複製代碼
SSH Servers,添加須要部署的遠程服務器,由於服務器ssh配置了免密登錄,因此不須要配置其餘。高級也能夠輸入密碼。系統設置修改apache
SSH登錄配置
# 登錄服務器生成密鑰
ssh-keygen
# 發送公鑰到須要目標服務器上
ssh-copy-id -i /root/.ssh/id_rsa.pub root@目標服務器主機ip
# 登錄
ssh root@目標服務器主機ip
複製代碼
全局工具配置修改tomcat
修改setting bash
修改JDK 修改maven構建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登錄服務器的路徑之上。沒有關注,打包好的文件路徑,是工做空間的相對路徑。修改文件的路徑和前綴後自動傳包成功。