@ [TOC]
http://192.168.2.5:181/view/all/newJob building a maven project ht-micro-record-service- note-provider
to add jenkins host public key to gitlab, and generate the global credentials
1.Username with password root / 123456
2.SSH Username with private key Enter Directly, add gitlab server private key
parent.relativePath revised to
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> <!--被依赖的包加该配置-->
<mainClass>com.ht.micro.record.commons.CommonsMapperApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
Micro Service 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的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
Q1:Failed to execute goal on project : Could not resolve dependencies for
Most of the parent project clean install, then most subprojects clean install
Q2: repackage failed: Unable to find main class -> [Help 1]
Construction of the main class appears to be missing
public class CommonsApplication {
public static void main(String[] args) {
}
}
详情见:
https://github.com/OneJane/blog
https://www.jianshu.com/u/b2a63c970be4