Q: Can I trigger a Jenkins job from a Maven plugin? - maven

The setup is as follows:
Step 1: I am developing on a windows 10 machine
Step 2: Building artifacts with Maven (using 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.
Q: Is it possible to automate/merge Steps 2 and 3 in this scenario?
(Building and deploying each takes several minutes)

Yes, you can.
Create a custom goal which will trigger the Jenkins with an URL.
But, ideally, I would suggest to build and deploy using Jenkins by fetching the code from the repository when there is a change

Yes you can.
I suggest you use webhooks (github, gitlab, bitbucket,...)
Steps will be :
Install some plugin in your jenkins in order to expose a job as public url.
Configure your webhook in git provider adding url created in step 1
Push some changes to your code
Your git provider detect this event and execute the url created in step 1
Your jenkins job is launched. Put your mvn commands and deploy commands in this job. 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

Related

How to setup a Jenkins job for Veracode Scan in a Node application?

My Jenkins runs on AWS EC2 instance and I'm creating a freestyle job to run Veracode Scan. I configured my Veracode portal API credentials with the Job. Installed the Veracode Jenkins plugin as well. And the Git repo also set upped in the pipeline. So my plan was to Zip the git repo by running below shell script
Then in the post build section I configured to upload the zip file like shown in below image.
When i build the job it throws below error.
it says that zip is not found. What may be the reason for this error? Also am I approaching this in a correct way?

How to configure Azure-DevOps release pipeline task to kick off automated UI test scripts on xcode in MacBook?

I have setup the Build pipeline in Azure-DevOps to generate build of xcode automation project. For that, I have used Microsoft hosted MacOS agent on my macbook. Now, i want to setup release pipeline to kick off automated test scripts from TFS/Azure-DevOps Server on the same macBook? Not sure what are the configuration I need to use in release pipeline task. If someone has done this, could you please help me step-by-step?
Did you mean you want the automated test from azure devops to run against your local macBook.
If this is your intention. You may need to setup a self-hosted macOS agent on you local macBook.
Please check here to create a self-hosted agent.
And in the release pipeline, associate your release pipeline to the build artifacts from your build pipeline. Make sure the build artifacts include your test code.If not you may need to add a publish artifact task in your build pipeline to include your test code in the build artifacts which will be downloaded and used in release pipeline.
In your stage create an agent job with the agent pool set to your agent pool with your self-host agent. And add a xcode task to run your test. When you run the release pipeline the test will run on your local macBook.
Here is documents about how to build, test and deploy with xcode. Hope you find above helpful.

Continuous Deployment of builds onto servers from build server

I'm using ansible to deploy and install builds on to my servers, but I have to feed Ansible with build name, to grab it and deploy. I would like to close this loop since I have to deploy the builds thrice a day. Is there a tool to do this so that everytime it sees a new build it will automatically invoke the ansible playbook. Or should I go ahead and write my own tool to do this. I'm open to suggestions.
Ansible itself can't do this for you.
But actually there are zillion of other options available: from simple crontab script to complete CI/CD tools such as Jenkins.
I have used jenkins for a while and I can confirm that Jenkins can do that for you.
Once a commit is done, can it compile your solution and deploy to required environment

How to deploy my Spring Boot project on Jenkins?

I am trying to create a deploy job in Jenkins for my Spring Boot - Maven project. These are the steps i have followed until now:
Click New Item
Give a name, and choose Maven project
Configuration page opens
In Source Code Management, i have given my Git repository URL
In Build section under Goals and options i have written "spring-boot:run"
Saved and applied
Now when i click "Build Now", it checks out the project, builds and deploys. But the job does not end. This is the last line in the console output screen:
: Started Application in 4.737 seconds (JVM running for 16.297)
What is my problem? I need a simple step by step guidance since i do not have any Jenkins experience.
EDIT: I do not know what post build action is which is mentioned in the other post. I need a simple step by step guidance since i do not have any Jenkins experience.
The job doesn't end because your application is up and running on embeeded Tomcat. It's normal behaviour and you should be able to use your application at this point.
If you want to make another build, you should stop current build before starting a new one. To do this automaticaly (e.g. when your master branch is changed) you can create another one job.
Example of a job that triggers build of a main job:
Create a 'Freestyle project' in Jenkins;
Fill 'Source Code Management': your Repository URL and Credentials, Branches to build - */master;
Fill 'Build Triggers': select 'Poll SCM' and type H/2 * * * * in 'Shedule' to poll repository every 2 minutes;
Fill 'Build': add build step 'Execute shell' and type next commands to stop current build and start a new one (don't forget to replace JENKINS_URL and JOB_NAME with your values) -
curl -X POST http://JENKINS_URL/job/JOB_NAME/lastBuild/stop;
curl -X POST http://JENKINS_URL/job/JOB_NAME/build;
Save your job :)
I think that if you are going to deploy the spring-boot application in another server different to jenkins server you need to build your app mvn clean package and to move the jar created from jenkins server to the new server then you can use another step to start the app using java -jar myapp.jar. But, if you are going to deploy in tomcat server then you can use tomcat-api to deploy remotely.

Jenkins CI + Ant + SSH Plugin

So the way I have this setup is:
Jenkins Polls for changes on repo
Jenkins Initiates Ant
Jenkins uses SSH plugin to run a script on a remove server (to run a git pull)
The problem is that if Ant fails, Jenkins still moves on to step 3 and processes the script.
How do I make Jenkins just stop everything after step 2? Or is there a better way of doing my process?
I think what I really needed was Publish Over SSH instead. This enables you to include it in the Post Build Options.

Resources