Wednesday, 12 October 2016

mvn command is not recognized as an internal or external command build step 'invoke top-level maven targets' marked build as failure jenkins

On my Windows 7 machine I have the following environment variables:
  • JAVA_HOME=C:\Program Files\Java\jdk1.7.0_07
  • M2_HOME=C:\apache-maven-3.0.3
On my PATH variable, I have (among others) the following:
  • %JAVA_HOME%\bin;%M2_HOME%\bin
I tried doing what you've done with %M2% having the nested %M2_HOME% and it also works.

NOTE:

on your jenkins go to Jenkins Dashboard

Manage jenkins  -----> Manage Jenkins ----> Global tool configueration ---> add PATH for JAVA_HOME and MAVEN_HOME.

Tuesday, 11 October 2016

Jenkins Github Authentication error: user is missing the Overall/Read permission

Task:

Access Denied

<user> is missing the Overall/Read permission

Solution:

This is how I resolved the authentication problem:
1.  Edit config.xml file, e.g.
2.  sudo vi /var/lib/jenkins/config.xml
1.  Change useSecurity element's value to false, e.g.
2.  <useSecurity>false</useSecurity>
3.  Remove authorizationStrategy block
3.  Restart Jenkins: /etc/init.d/jenkins restart.
4.  Access Jenkins through URL as usual and reconfigure security again.

Wednesday, 5 October 2016

Scheduling tasks in Jenkins

To schedule a cron job every 5mins you need to define the cron settings like this: */5 * * * *
*/5 * * * * means every 5 minutes
5 * * * * means the 5th minute of every hour
 
 
Jenkins lets you set up multiple times, separated by line breaks.
 If you need it to build daily at 7am, along with every Sunday at 4pm, the below works well
 H 7 * * *
H 16 * * 0
 
use */5 * * * * for every 5mins
 
By setting the schedule period to 15 13 * * * you tell jenkins to schedule the build every day of every month of every year at the 15th minute of the 13th hour of the day.
What Jenkins used is a cron expression, the different fields are :
1.  MINUTES Minutes in one hour (0-59)
2.  HOURS   Hours in one day (0-23)
3.  DAYMONTH    Day in a month (1-31)
4.  MONTH   Month in a year (1-12)
5.  DAYWEEK Day of the week (0-7) where 0 and 7 are sunday
If you want to shedule your build every 5 minutes, this will do the job : */5 * * * *
If you want to shedule your build every day at 8h00, this will do the job : 0 8 * * *
 To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) should be used wherever possible.
For example, using 0 0 * * * for a dozen daily jobs will cause a large spike at midnight. In contrast, using H H * * * would still execute each job once a day, but not all at the same time, better using limited resources.
Note also that :
The H symbol can be thought of as a random value over a range, but it actually is a hash of the job name, not a random function, so that the value remains stable for any given project