jenkin项目配置

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lh87270202/article/details/84292579

前言

其实已经配置过很多项目,但时间一长 一些细节问题忘了,又浪费了一些时间,所以这里记录一下容易忘记的点

1、jenkins配置

1、post step (前面的配置没有疑问,从这一步开始记录)
在这里插入图片描述
这个是脚本,代码从git上拉下来后,到jenkins的工作目录去打包。
2、构建后操作
在这里插入图片描述
3、构建后操作中ssh server配置
配置ssh server就是你需要把Jenkins上打好的jar包,上传到部署的服务器上
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
4、spring boot 打包配置
这一部分主本解决下面2个问题:
a、指定被打包的文件名,如果不指定jar后会带版本号,这样如果版本号变化启动脚本就需要变化
b、解决no main manifest attribute, in test.jar 找不到mainifest

<build>
        #这里指定finalName,打包名就是这个,不会带上版本号
        <finalName>test</finalName>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.yml</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
      #spring boot打包插件,加上就不会报no  mainifest
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            
        </plugins>
    </build>
5、补充一个手动启动Jar包的命令

如果不执行构建后操作shell脚本,登录服务器,cd到部署服务器的目标路径下,就可以看到Jenkins上打好的jar包已经上传到,部署服务机器上去了,直接在目录执行下面命令的也可以启动服务(jar包名换成对应的jar包名即可)
即使关闭shell也不会停止服务

nohup java -jar test.jar & 

猜你喜欢

转载自blog.csdn.net/lh87270202/article/details/84292579