简体   繁体   English

问:我可以通过Maven插件触发Jenkins作业吗?

[英]Q: Can I trigger a Jenkins job from a Maven plugin?

The setup is as follows: 设置如下:

  • Step 1: I am developing on a windows 10 machine 步骤1:我在Windows 10机器上进行开发
  • Step 2: Building artifacts with Maven (using powershell) 步骤2:使用Maven构建工件(使用PowerShell)
  • Step 3: Go to (semi-local) Jenkins which is running in a Linux VM on my machine & trigger a Jenkins job that syncs and deploys my artifacts to the application server running on the VM. 步骤3:转到在我的计算机上的Linux VM中运行的(半本地)Jenkins,并触发Jenkins作业,该作业将我的工件同步并将其部署到VM上运行的应用程序服务器。

Q: Is it possible to automate/merge Steps 2 and 3 in this scenario? 问:在这种情况下是否可以自动/合并步骤2和3?

(Building and deploying each takes several minutes) (每次构建和部署都需要几分钟)

Yes, you can. 是的你可以。

Create a custom goal which will trigger the Jenkins with an URL . 创建一个自定义目标,该目标将使用URL触发Jenkins。

But, ideally, I would suggest to build and deploy using Jenkins by fetching the code from the repository when there is a change 但是,理想情况下,我建议在发生更改时通过从存储库中获取代码来使用Jenkins进行构建和部署

Yes you can. 是的你可以。

I suggest you use webhooks (github, gitlab, bitbucket,...) 我建议您使用webhooks(github,gitlab,bitbucket等)

Steps will be : 步骤将是:

  1. Install some plugin in your jenkins in order to expose a job as public url. 在jenkins中安装一些插件,以将作业公开为公共URL。
  2. Configure your webhook in git provider adding url created in step 1 在git provider中配置您的webhook,添加在步骤1中创建的url
  3. Push some changes to your code 向您的代码推送一些更改
  4. Your git provider detect this event and execute the url created in step 1 您的git提供者检测到此事件并执行在步骤1中创建的url
  5. Your jenkins job is launched. 您的詹金斯工作已启动。 Put your mvn commands and deploy commands in this job. 将您的mvn命令和部署命令放在此作业中。 I suggest you use jenkins pipeline job. 我建议您使用詹金斯管道作业。

Contact me if you need some help. 如果需要帮助,请与我联系。

Post step by step : 逐步发布:

https://jrichardsz.github.io/devops/devops-with-git-and-jenkins-using-webhooks https://jrichardsz.github.io/devops/devops-with-git-and-jenkins-using-webhooks

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以使用Maven依赖项触发Jenkins作业吗? - Can I trigger a Jenkins job using a Maven dependency? 如何从远程 Jenkins 触发本地 maven 项目? - How can I Trigger local maven project from remote Jenkins? 是否有一个Maven插件来创建Jenkins作业 - Is there a Maven plugin to create Jenkins job 你可以使用在Jenkins上使用HermesJMS的SoapUI插件运行maven作业吗? - Can you run a maven job with the SoapUI plugin that uses HermesJMS on Jenkins? 如何使用Gerrit在Jenkins中触发特定于Maven的工作 - How to trigger maven specific job in Jenkins with Gerrit 我怎么能告诉jenkins我确实想要maven工作的完整错误跟踪? - How can I tell jenkins I do want the full error trace from a maven job? 如何在每个作业中从 config-file-provider 插件设置 Jenkins 配置(默认) - How can I set Jenkins configuration from config-file-provider plugin in every job (per default) 如何使用Artifactory插件和Credentials插件将Jenven的Maven工件部署到Artifactory时解决401失败? - How can I resolve a 401 failure when deploying a Maven artifact from Jenkins to Artifactory using the Artifactory Plugin and the Credentials Plugin? 如何在Jenkins上配置Maven构建作业以告诉SonarQube构建作业的URL? - How can I configure Maven build job on Jenkins to tell SonarQube the build job's URL? Jenkins作业使用Maven-release-plugin自动转换吗? - Jenkins job auto-versioning with maven-release-plugin?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM