Checkout and build project using Jenkins - maven

I have successfully configured the SVN repository url in Jenkins and now i want to build that project through Jenkins, but i want some clarification as i am new to Jenkins.
Can i download the code using Jenkins to my local repository without installing any Subversion software?
If yes, please enlighten me.. If No, may i know the reason or any alternative..
Based on 2 step, i want to build the project(Maven) using Jenkins.. for that i have specified the Root POM option in build step... when i am using the SVN URL to located the POM.xml, it is displaying an error in Jenkins as No such file: ‘http://<POM.xml path>
Please advise, thanks in advance

Build a job with only SCM configured on a machine with no client installed and see what happens. it'll answer your question
Regarding the root pom - you've already checked out your repository, use the local file in your workspace: $WORKSPACE/Path/To/pom.xml
For poll SCM scheduler you can use:
MINUTE HOUR DOM MONTH DOW
MINUTE Minutes within the hour (0–59)
HOUR The hour of the day (0–23)
DOM The day of the month (1–31)
MONTH The month (1–12)
DOW The day of the week (0–7) where 0 and 7 are Sunday.
Example:
*/2 * * * * will run every 2 minutes.

Related

How I can access to a file saved in Gitlab CI/CD artifact in the next stages and increase it's version

I have a spring boot application and I deployed it in the first stage and now I have a jar file.
my question is how to access this jar file in the next stage and how I can run it.
second question is HOW can I increase its version number? for example jar file name is spring.0.0.1.jar and I want to increase version number after every push. is this possible?
First Question:
You can save the jar file as an artifact and access it in the second stages jobs' script area. For example
FirstJob:
stage: FirstStage
scrip:
- <your commands here>
artifacs:
paths:
- ./artifacts/myOutput.jar
Now your "myOutput.jar" is accessible in the artifacts folder for all following jobs. See here: https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html
Second Question:
As far as I know there is no way of handing down variables between pipelines in GitLab CI so this would not be possible if I'm right. Since artifacts don't get added to the repository, previous artifacts are not available to following pipelines either. Yet, if I had to come up with a solution on the spot, I'd try:
Saving the version number somewhere accessible to every pipeline (cloud, repo)
git push every artifact to actually add it to the repository, then check file name and increment version number
using the GitLab CI release option. The CI can create a release object for you, maybe this could help as well. See here: https://docs.gitlab.com/ee/ci/yaml/README.html#release

Bamboo build error: How to properly clean bamboo caches?

The problem:
Bamboo executes old unit tests that don't exist my current develop branch which causes a build error.
The situation that causes this problem:
After a big refactoring process of my maven java project, where I basically moved, modified and renamed every file, I committed my changes to my remote repository.
That triggered my bamboo build plan, to start the build process.
The git code checkout seems to work, but the next step, running the unit tests, fails!
Looking in the log file I see that an old, no more existing java Unit test class gets executed and of course fails because of NullPointerExceptions.
Things I tried to fix this problem
A. Remove caches in the Administration section
I went to Bamboo->Administration->Repository Settings and selected
the cache of my project and deleted it.
I started the build plan again
BUILD ERROR ! Same problem
B. Delete the cache directory in the file system
Start a RDP session on the bamboo server
stop bamboo
go to D:\bamboo-home_64\xml-data\build-dir_git-repositories-cache
delete all files in this folder
start bamboo
start the build plan again
BUILD ERROR! same problem
Meta info
bamboo version: 6.1.0 build 60103 - 18 Jul 17
I don't know what I can do to fix this..
There's Clean working directory task. Add it as first task to your Job and see if it solves the issue.

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.

Printing time-stamp after each child module build in Maven

I am building a number of maven projects from the level of their parent.Some of the projects have child modules of their own. Is there a way to print the time-stamp after each module is built?
I suggest using the maven ant-run plugin.
You can add an execution bound the last step (install or deploy) which will print out the time stamp of your choice.
See examples here.
Also you can try the maven exec plugin and just run the system command date (linux) or date /T (windows).
I hope this helps.

Run maven install only if files changed in scm

I have a Jenkins build which basically does the following:
1) svn update
2) mvn clean install
3) run some custom deploy script
How do configure this job to skip step 2) if there are no changed files in SVN?
I don't need to rebuild the WAR if nothing changed.
I thought that this is what the "incremental build" checkbox is for, but that didn't work.
Thank you!
Addd Polling on SVN. WHich will trigger build only if there is a change
In your build configuration, under "Build Triggers" add a Poll Scm. If you want Jenkins to check for changes every minute type * * * * * in the schedule box. Otherwise, use the blue question mark next to the schedule box to help you with cron syntax.

Resources