如何在Jenkins上部署我的Spring Boot项目? [英] How to deploy my Spring Boot project on Jenkins?

查看:123
本文介绍了如何在Jenkins上部署我的Spring Boot项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Jenkins中为我的Spring Boot-Maven项目创建一个部署作业.这些是我到目前为止所遵循的步骤:

I am trying to create a deploy job in Jenkins for my Spring Boot - Maven project. These are the steps i have followed until now:

  • 点击新项目
  • 命名,然后选择Maven项目
  • 打开配置页面
  • 在源代码管理中,我给出了我的Git存储库URL
  • 在目标和选项"下的构建"部分中,我编写了"spring-boot:run"
  • 保存并应用

现在,当我单击立即构建"时,它将检出项目,进行构建和部署.但是工作并没有结束.这是控制台输出屏幕中的最后一行:

Now when i click "Build Now", it checks out the project, builds and deploys. But the job does not end. This is the last line in the console output screen:

: Started Application in 4.737 seconds (JVM running for 16.297)

我的问题是什么?由于我没有任何詹金斯经验,因此我需要一个简单的分步指导.

What is my problem? I need a simple step by step guidance since i do not have any Jenkins experience.

我不知道在另一篇文章中提到的是什么文章构建动作.由于我没有任何詹金斯经验,因此我需要一个简单的分步指导.

I do not know what post build action is which is mentioned in the other post. I need a simple step by step guidance since i do not have any Jenkins experience.

推荐答案

该作业不会结束,因为您的应用程序已启动并在嵌入式Tomcat上运行.这是正常现象,此时您应该可以使用您的应用程序.

The job doesn't end because your application is up and running on embeeded Tomcat. It's normal behaviour and you should be able to use your application at this point.

如果要进行其他构建,则应在开始新构建之前停止当前构建.要自动执行此操作(例如,在更改主分支时),您可以创建另一个作业.

If you want to make another build, you should stop current build before starting a new one. To do this automaticaly (e.g. when your master branch is changed) you can create another one job.

触发主作业构建的作业示例:

Example of a job that triggers build of a main job:

  • 在詹金斯创建一个自由式项目";
  • 填写源代码管理":您的存储库URL和凭据,要建立的分支-*/master;
  • 填写构建触发器":选择轮询SCM",然后在计划"中键入H/2 * * * *每隔2分钟轮询一次存储库;
  • 填充构建":添加构建步骤执行外壳"并键入下一个命令以停止当前构建并开始新的构建(不要忘记用您的值替换JENKINS_URL和JOB_NAME)-

  • Create a 'Freestyle project' in Jenkins;
  • Fill 'Source Code Management': your Repository URL and Credentials, Branches to build - */master;
  • Fill 'Build Triggers': select 'Poll SCM' and type H/2 * * * * in 'Shedule' to poll repository every 2 minutes;
  • Fill 'Build': add build step 'Execute shell' and type next commands to stop current build and start a new one (don't forget to replace JENKINS_URL and JOB_NAME with your values) -

curl -X POST http://JENKINS_URL/job/JOB_NAME/lastBuild/stop;
curl -X POST http://JENKINS_URL/job/JOB_NAME/build;

  • 保存您的工作:)

  • Save your job :)

    这篇关于如何在Jenkins上部署我的Spring Boot项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆