1

In our spring-boot project we are using local Git setup so all developer pull and push code in our in house git server.
That means the Git structure of our project is like that under one_project (project name) repository we have sub folders named api, ui, common, notification, authentication, etc..., which have there separate pom.xml but having one .git file, all of which is present in one_project repository.
Here is a rough structure of our project in image:

project

Now I have to use Jenkins to build these on two different provisioned Virtual Machines: machine A and machine B

So if I have to build and deploy jar of api, ui, common on machine A and notification,authentication, common on machine B,

NOTE THAT common use on both VMs

Question:
How to create a Jenkins job using slave nodes so that if developer fix bug or new code on any of one sub module and willing to make it build on provisioning VMs using Jenkins token (JENKINS_URL/job/one_project/build?token=api), so it only makes a fresh build of only that eg. api, not others and same for other two?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
adg
  • 99
  • 6

1 Answers1

1

only make a fresh build of only that eg. API, not others and same for other two.

The reality is: Jenkins does not "make a build": it only orchestrates jobs composed of build step. And each of those build step can be anything you want: an actual build process, or a deployment one, or a cleanup one, or... anything.

When Jenkins will launch the job, said job will start by fetching and do a checkout of the repo.

You can then have as a first "build" step a script in charge of listing the changes since the last successful build.
By parsing the result of a git log --name-only, that script can determine which main subfolders have changed and needs to be rebuilt. It can then set an environment variable which can be used by the second build step, another script which will go to the relevant subfolders and launch the actual build.

The point is: all those build steps are scripts which will do whatever you want, and should be written and tested locally first, outside of Jenkins.
Once you have a script able to determine what should be rebuilt, you can integrate easily that script into a Jenkins Job definition.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250