1
votes

I am learning Jenkins. Can someone tell me if my understanding is correct?

To build the app:

  • I commit my code and push my branch to my remote repository.
  • Jenkins sees my commit and triggers off a build (possibly using maven install).
  • Jenkins runs all the tests and if all pass, a war/ear is created. This artefact is pushed to nexus.

To deploy to an environment:

  • A deploy script in my branch contains steps to deploy the app to, say, Tomcat. Jenkins goes to Nexus, retrieves the latest artefact (built above), and deploys this app to Tomcat.
  • Other steps in the deploy file shutdown and restart Tomcat as necessary, possibly testing to make sure the app started and is ready to serve requests.

Am I right in saying that a deploy doesn't need to build the latest artefact, that it uses that last one pushed to Nexus, or is a fresh one built every deploy?

1
Quickly explained - you create a PR -> Jenkins run all the tests -> Merge PR button gets available for reviewer if build is successful-> PR gets merged -> snapshot gets generated in nexus-> now you test snapshot in UATE or preprod if functional tests are good to go-> then push the release cut to nexus. - Shek
Depends on your case, maybe you are using Maven, or Gradle to build your project. Those tools already have tasks to deploy on nexus, either deploy your artifacts on production using the actual artifact generated on /target path. - CleitonCardoso
new build only gets generated upon a new successful PR merge. - Shek

1 Answers

1
votes

It's all according to how you set up your build on Jenkins and/or git.

Jenkins can be configured to monitor your repository (repo, for short) and to kick off a build when it detects a change.

Jenkins can be configured to run a build. You provide the Maven command-line arguments; Jenkins just orchestrates the commands you give it.

Some of the steps you provide Jenkins will be shell code. This is how you can run custom shell scripts, say to access Nexus. Things don't happen by themselves; if you tell Jenkins to deploy an artifact, say by using Maven, then Jenkins will invoke the deployment command as you told it to.

It is highly irregular for an app deployment to arrogate responsibility to start, restart, or shut down your server (Tomcat). That could be done via Jenkins, sure, but it's at a higher "pay grade" than an app deployment should have. Keep it simple; if your Jenkins build is managing an app for testing and deployment, keep its focus on the app and not on the server.

Jenkins is magical, but it's not a mind reader. It will do none of the things you said unless you tell it to. That said, the process you outlined is a reasonable one, whatever tool you use to enact it. Jenkins certainly can do those things, if you set it up accordingly.