Saturday, 29 February 2020



1) Please go through my earlier blog:- HOW TO INVOKE ANSIBLE PLUGIN IN JENKINS

2) During the execution of Date job in Jenkins, I faced 2 errors:-

a) ERROR: Unable to install JDK unless a valid Oracle account username/password is provided in the system configuration.Finished: FAILURE

Solution:- Go to Manage Jenkins

Then Go to Global tool configuration

Under Global Tool configuration, click on Jdk Installation

Uncheck the option - Install Automatically to solve this issue.

b) Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this

Solution:- To solve this issue, go to to ansible.cfg file under the ansible folder

Edit the ansible.cfg file and uncomment the line -  host_key_checking = false and save the file.

3) Now let us create our first job in Jenkins.

1) Click on Create New Job

2) Enter the name of the item and click OK. I have taken the example as date

3)  In the description box, type the required description.

4) In the build section, click on Add build Step and choose Invoke Ansible Playbook

5) Specify the path of the playbook which is kept on your ansible server. Also specify the path of the host file.

6) Now click on Credentials and add the credentials of the ansible server, as shown below:

Click on Add

7) Make sure that you have credentials specified, as shown in the below screenshot.

8) Click on Apply and save the file.

9) To run the Jenkins job, click on Build Now.

10) This would execute the Jenkins Job - Date.

11)  To check the status of the Job, click on the build number and console output.

12) Note:- If we need to schedule the job to run every minute, we need to do the below entry under Build Triggers:-

Jenkins can be used a cron expression, and the different fields are as given below:

    MINUTES Minutes in one hour (0-59)
    HOURS Hours in one day (0-23)
    DAYMONTH Day in a month (1-31)
    MONTH Month in a year (1-12)
    DAYWEEK Day of the week (0-7) where 0 and 7 are sunday

Schedule the build every 5 minutes, this will do the job : */5 * * * *

Schedule the build every day at 8h00, this will do the job : 0 8 * * *

No comments:

Post a Comment