GitLab+jenkins+docker release

Keywords: Docker Maven github jenkins

Article directory

http://192.168.2.5:181/view/all/newJob Build a maven project HT micro record service note provider
Add jenkins host public key to gitlab and generate global credentials
1.Username with password root/123456
2.SSH Username with private key Enter Directly, add the private key of gitlab server

parent.relativePath is modified to set a null value when publishing a single service, which will always be obtained from the warehouse, not from the local path.

Basic services

<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>  <!--Add the configuration to the dependent package-->
                <mainClass>com.ht.micro.record.commons.CommonsMapperApplication</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

Microservice provider

<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 Of maven Plug in, official website 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

[external link picture transfer failed (img-ndp8uqpe-156379666860)( https://www.github.com/OneJane/blog/raw/master/small calligrapher/1563789548337.png)]
[external link picture transfer failed (img-f3ctnjcf-156379666860)( https://www.github.com/OneJane/blog/raw/master/small calligrapher/1563789561923.png)]
[external link image transfer failed (img-tyxyqffw-156379666862)( https://www.github.com/OneJane/blog/raw/master/small calligrapher/1563789568408.png)]

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

For the most parent project clean install, and then the most child project clean install

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

Build display missing main class

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


    }
}

For details, see:
https://github.com/OneJane/blog

Posted by V34 on Fri, 18 Oct 2019 13:25:54 -0700