GitLab+jenkins+docker发布.md

@[TOC]

http://192.168.2.5:181/view/all/newJob 构建一个maven项目ht-micro-record-service-note-provider

添加jenkins主机公钥到gitlab,并生成全局凭据

1.Username with password root/123456

2.SSH Username with private key Enter Directly,添加gitlab服务器私钥

parent.relativePath修改为,发布单个服务时设定一个空值将始终从仓库中获取,不从本地路径获取

基础服务

<build>
    <finalName>ht-micro-record-commons-domain</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <classifier>exec</classifier>  <!--被依赖的包加该配置-->
                <mainClass>com.ht.micro.record.commons.CommonsMapperApplication</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

微服务提供者

<build>
    <finalName>ht-micro-record-service-note-consumer</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>com.ht.micro.record.service.consumer.NoteConsumerServiceApplication</mainClass>
            </configuration>
        </plugin>
        <!-- docker的maven插件,官网 https://github.com/spotify/docker-maven-plugin -->
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.4.13</version>
            <configuration>
                <imageName>192.168.2.5:5000/${project.artifactId}:${project.version}</imageName>
                <baseImage>jdk1.8</baseImage>
                <entryPoint>["java", "-jar","/${project.build.finalName}.jar"]</entryPoint>
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
                <dockerHost>http://192.168.2.5:2375</dockerHost>
            </configuration>
        </plugin>
    </plugins>
</build>

Jenkins

export app_name="ht-micro-record-service-note-consumer"

export app_version="1.0.0-SNAPSHOT"

sh /usr/local/docker/ht-micro-record/deploy.sh

#!/bin/bash

DATE=`date +%F-%H-%M-%S`
last_app_name=`echo "$app_name-$app_version-$DATE"`
if docker ps | grep $app_name;then
  docker stop $app_name
  docker rename $app_name $last_app_name
  docker run -di --name=$app_name --net=host 192.168.2.5:5000/$app_name:$app_version

elif docker ps -a | grep $app_name;then
  docker start $app_name
else
  docker run -di --name=$app_name --net=host 192.168.2.5:5000/$app_name:$app_version
fi

vim /usr/local/bin/dokill

docker images | grep -e $*|awk ‘{print $3}‘|sed ‘2p‘|xargs docker rmi
chmod a+x /usr/local/bin/dokill
dokill tensquare_recruit

enter description here

Q1:Failed to execute goal on project : Could not resolve dependencies for

对最父级项目clean install,再最子项目clean install

Q2: repackage failed: Unable to find main class -> [Help 1]

构建显示缺少主类

public class CommonsApplication {
    public static void main(String[] args) {

    }
}

详情见:

https://github.com/OneJane/blog

https://www.jianshu.com/u/b2a63c970be4

原文地址:https://www.cnblogs.com/codewj/p/11227859.html

时间: 2024-07-31 23:38:30

GitLab+jenkins+docker发布.md的相关文章

GitLab + Jenkins + Docker + Kubernetes。

目前方案是GitLab + Jenkins + Docker + Kubernetes. 方案的工作流程如下:首先,开发人员提交代码代码提交:随后,GitLab 会自动触发Jenkins job,Jenkins job会构建相应的镜像,放在一个Kubernetes的Pod里面:接下来,Kubernetes的Pod会把模块需要的其他依赖都包含在其内部(比如MySQL.Redis.MongoDB等),运行robot测试用例,测试用例的结果最后会反馈到Jenkins中:所有测试通过之后,GitLab把

第四十四章 微服务CICD(6)- gitlab + jenkins + docker + k8s

总体流程: 在开发机开发代码后提交到gitlab 之后通过webhook插件触发jenkins进行构建,jenkins将代码打成docker镜像,push到docker-registry 之后将在k8s-master上执行rc.service的创建,进而创建Pod,从私服拉取镜像,根据该镜像启动容器 在第四十三章 微服务CICD(5)- gitlab + jenkins + docker中,实现了前两步.本节实现第三步 一.打通jenkins与k8s-master两台机器之间的ssh无密码访问

gitlab + jenkins + docker + k8s

总体流程: 在开发机开发代码后提交到gitlab 之后通过webhook插件触发jenkins进行构建,jenkins将代码打成docker镜像,push到docker-registry 之后将在k8s-master上执行rc.service的创建,进而创建Pod,从私服拉取镜像,根据该镜像启动容器 在第四十三章 微服务CICD(5)- gitlab + jenkins + docker中,实现了前两步.本节实现第三步 一.打通jenkins与k8s-master两台机器之间的ssh无密码访问

Gitlab+Jenkins+Docker实现net core持续集成

前言 在项目中使用这一套自动集成的体系之后,一直想找个时间总结出来,用于自己记录也打算将自己的所得分享给园友们,不经常写文章,可能会有错误的地方,希望各位不吝指正,我会及时的改正并表示感谢,希望大家能够一起进步. 前期准备 centos7.5系统环境,关闭防火墙 jenkins in docker 安装 yum install docker docker service start docker pull jenkins docker run -d -p 8080:8080 -p 50000:5

gitlab+jenkins环境搭建.md

gitlab+jenkins自动化部署环境搭建 环境说明 系统 主机 IP 安装软件 CentOS 7 study-1 192.168.100.51 gitlab.git CentOS 7 study-2 192.168.100.52 jdk.maven.jenkins.git CentOS 7 study-3 192.168.100.53 tomcat.mysql.jenkins.git 所有系统的selinux和iptables都已经关闭,同时需要做好时间同步,机器的hosts文件如下: 1

第四十三章 微服务CICD(5)- gitlab + jenkins + docker

一.总体流程 部署: 开发机(mac) ip:11.11.11.11 docker:1.12.1 部署机(centos7) ip:10.211.55.4 docker:1.12.3 生产机(centos7) ip:10.211.55.3 docker:1.10.3(装k8s1.4的时候自带安装的版本) 总体流程: 在开发机开发代码后提交到gitlab 之后通过webhook插件触发jenkins进行构建,jenkins将代码打成docker镜像,push到docker-registry, 之后将

1)gitlab+jenkins自动化发布;gitlab搭建

安装gitlab 参考文档: https://www.yiibai.com/gitlab/gitlab_introduction.html 1.下载epel源 wget http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm 2.wget -O /etc/yum.repos.d/CentOS-Base.repo 3.关闭防火墙和seLinux 4. yum install curl policycoreutils opens

jenkins+gitlab+微服务发布+k8s发布

背景:jenkins+gitlab+微服务发布+k8s发布实现自动更新1.配置jenkins pipeline pipeline语法`node {try {stage('代码拉取') {git credentialsId: 'xiongxj', url: '[email protected]:xinjiang.xiong/oam.git' } stage('项目构建') { sh " /opt/software/apache-maven-3.6.0/bin/mvn clean package&q

Jenkins+docker实现应用发布和更新

Jenkins+docker实现应用发布 Jenkins:centos6.5 ip:192.168.83.84 Docker:centos7.2 ip:192.168.83.60 一.安装Jenkins 最新版: sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo rpm --import http://pkg.jenkins-ci.org/redhat/jen