CentOS+Docker+Jenkins+Gradle+Git

2019-12-09  本文已影响0人  安安静静的码代码

前言

打个广告 ~ 移动端离线鉴黄实现,可移植到多个平台,让鉴黄付费不存在~ open_nsfw

更新yum源

yum update

安装必要软件

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

设置yum下载源为阿里仓库(网速ok的可以省略这一步)

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

查看仓库中所有的docker版本

yum list docker-ce --showduplicates | sort -r

选择一个版本进行安装(下面的xxxx换成要安装的docker)

sudo yum install xxxx

等待安装结束后,启动docker 并设置docker开机自启,代码如下

sudo systemctl start docker && sudo systemctl enable docker

查看docker版本

docker version

安装项目需要的软件,我项目需要redis和mysql,以下为示例命令,需要其他软件的可参考以下命令

docker pull redis
docker run -d -v /etc/localtime:/etc/localtime --name redis -p 6379:6379 redis --requirepass 123456
docker pull mysql 
docker run -p 3306:3306 -v /etc/localtime:/etc/localtime --name mysql  -e MYSQL_ROOT_PASSWORD=123456 -d mysql

现在远端可以使用响应工具链接MySQL和Redis了

同上方式安装Jenkins

docker pull  jenkins/jenkins:lts
mkdir /home/jenkins_home
docker run -u root -d  -v /etc/localtime:/etc/localtime --name jenkins -p 80:80 -p 443:443 -p 8888:8080 -p 50000:50000 -v /home/jenkins:/home/jenkins jenkins/jenkins:lts
docker exec -it jenkins bash
cat /var/jenkins_home/secrets/initialAdminPassword
http://你的服务器地址:8080/jenkins/github-webhook
bootJar {
    doFirst {
        println 'Start BootJar task...'
        baseName = 'wb-spring-boot'
        version = '1.3'
    }
    doLast {
        println 'BootJar success.'
    }
}
}
c_s.png gitsp.png
docker exec -it jenkins bash
cd /
wget https://downloads.gradle.org/distributions/gradle-4.8-all.zip
unzip gradle-4.8-all.zip
rm -rf gradle-4.8-all.zip
apt-get update
apt-get install vim
vim /etc/profile
etc.png
PATH=$PATH:/gradle-4.8/bin
export PATH
source /etc/profile
gradle -v

Welcome to Gradle 4.8!

Here are the highlights of this release:
 - Dependency locking
 - Maven Publish and Ivy Publish plugins improved and marked stable
 - Incremental annotation processing enhancements
 - APIs to configure tasks at creation time

For more details see https://docs.gradle.org/4.8/release-notes.html


------------------------------------------------------------
Gradle 4.8
------------------------------------------------------------

Build time:   2018-06-04 10:39:58 UTC
Revision:     9e1261240e412cbf61a5e3a5ab734f232b2f887d

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM:          1.8.0_232 (Oracle Corporation 25.232-b09)
OS:           Linux 3.10.0-1062.1.1.el7.x86_64 amd64
#!/bin/bash
echo 打包成功,开始运行jar;
#进程处理
/bin/fuser -k -n tcp 80
BUILD_ID=DONTKILLME
java -jar /var/jenkins_home/workspace/WB-Service/build/libs/wb-spring-boot-1.3.jar &
echo 构建成功
docker exec -it jenkins bash
apt-get install psmisc
root@df727b881c6f:/# whereis fuser
fuser: /bin/fuser /usr/share/man/man1/fuser.1.gz
root@df727b881c6f:/# 
docker ps
docker inspect -f '{{.ID}}' jenkins
docker cp WB-Service.zip 42b70191d27fcf0164abb36e33e223da52e306d49d6d5348e55663caac96bb82:/var/jenkins_home/workspace/
docker exec -it jenkins bash
cd /var/jenkins_home/workspace/
unzip WB-Service.zip
rm -rf WB-Service
mv wb-spring-boot-project WB-Service
cccc.png push2.png

至此 自动部署完成~ 来自一个入行一个月的java开发猿... 大佬多多指教。

打个广告 ~ 移动端离线鉴黄实现,可移植到多个平台,让鉴黄付费不存在~ open_nsfw

上一篇下一篇

猜你喜欢

热点阅读