0

I am working on Multibranch pipelines in Jenkins.We use SVN as repository and maven for build. I have placed the jenkins file in each branch.

In jenkins file,

After initial checkout, I wrote a function to iterate over the workspace and add the folder names to the list that needs to be build ahead.

In Build stage, I used the list size to iterate using for loop, navigate to the directory and run maven command inside the folder where the POM file is located. Issue i am trying to solve is, when there is changes in one of the projects under branch, it runs build for all projects due to above configuration. I am looking for some guidance to run build only for changes using pipelines.

Code Snippet - for ( int i = 0; i < size; i++) {

              dir(dirsl[i]) {
              try {

                  withMaven(jdk: 'Java7', maven: 'localmaven') {
                  bat "mvn clean package"
                 }
              }
              catch (e) {
              println e
              }

             }

Also not sure if this is the right way to build using Maven.

sundar s
  • 66
  • 6
  • Why do you need to iterate over the workspace ? If you have a repository you build exactly one project in a branch not multiple ... – khmarbaise Apr 09 '18 at 15:25
  • Single branch will multiple projects to be build seperately. This is used for Oracle OSB projects. That is the reason i decided to iterate. – sundar s Apr 09 '18 at 15:54
  • A branch with multiple projects is not a good idea to do on multi branch pipeline cause the concept is thought different. – khmarbaise Apr 09 '18 at 16:09
  • Okay, so how should i proceed for this case? Even with pipeline, i will end up in building entire branch if same script is used. Any leads would be helpful. – sundar s Apr 09 '18 at 16:27
  • Usually you have a single project (trunk/several branches) in SVN. This project can of course comprise of multiple modules but the whole project will built...If I correctly understand you misusing the trunk/branch concept of SVN ? Can you explain that more in detail... – khmarbaise Apr 09 '18 at 19:04
  • We have several OSB projects in SVN which is considered as seperate module and maintained in trunk. Whenever there is new work request, we export copy from trunk of invidual modules that has impact due to that particular work request as new branch. This branch will be used for build and deploy which we do manually now. Once it is moved to production, we do merge with trunk and archive the branch. – sundar s Apr 10 '18 at 09:23

0 Answers0