简体   繁体   English

Jenkins使用Gradle子项目进行构建

[英]Jenkins builds with gradle subprojects

Is there anyway I can create a two module projects in gradle, and trigger a build for each module by itself? 无论如何,我可以在gradle中创建两个模块项目,并单独触发每个模块的构建吗?

Root project 'Example' 
    Jenkinsfile
\--- Project ':SubProject'
    Jenkinsfile

I want that jenkins will trigger a build only in the module that has been changed. 我希望詹金斯只在已更改的模块中触发构建。


for example : 例如

If my SubProject changed, then only SubProject will execute it's own Jenkinsfile . 如果我的SubProject更改了,那么只有SubProject会执行它自己的Jenkinsfile

I looked up for this option for a very long time... 我很长一段时间都在寻找这个选项...

As you can see in the other questions, there is no any easy way to achieve that. 正如您在其他问题中看到的那样,没有任何简单的方法可以实现这一目标。

Is there any Jenkins pipeline or plugin that can deal with that? 是否有任何Jenkins pipelineplugin可以处理?

  • It is relatively easy to only invoke the gradle tasks from a given subproject: 仅从给定的子项目中调用gradle任务相对容易:
    • To build Example : ./gradlew :build 构建示例./gradlew :build
    • To build SubProject : ./gradlew :SubProject:build 要构建SubProject./gradlew :SubProject:build
    • Gradle will then only run the task graph these invocation define. 然后,Gradle将仅运行这些调用定义的任务图。
  • It should be relatively easy to setup two different jobs in Jenkins, based on distinct Jenkinsfile, and each could have the custom invocation defined above. 在Jenkins中基于不同的Jenkinsfile设置两个不同的作业应该相对容易,并且每个作业都可以具有上面定义的自定义调用。

However, the triggering of one project only will most likely be the tricky thing as they most likely live in the same source control location. 但是,触发一个项目很可能是一件棘手的事情,因为它们很可能生活在同一源代码控制位置。

Maybe the easy fix is also to have them decoupled, using svn:externals or Git submodules. 也许简单的解决方法是使用svn:externals或Git子模块将它们解耦。

Use excludedRegions to exclude folders/files that would trigger a build. 使用excludedRegions排除将触发构建的文件夹/文件。

https://jenkins.io/doc/pipeline/steps/workflow-scm-step/ https://jenkins.io/doc/pipeline/steps/workflow-scm-step/

I'm unsure about the support of JenkinsFile... 我不确定JenkinsFile的支持...

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM