Showing posts with label jenkins. Show all posts
Showing posts with label jenkins. Show all posts

Wednesday, November 29, 2017

How to add windows node to Jenkins

Login to Jenkins portal and click on Manage Jenkins link.
Scroll down and click on Manage Nodes.
Click on new node link left side.
1.png
Provide node details and press OK.
2
Click on save after providing below details.
3.png
4
Now login to the Jenkins portal on the machine which we want to add as node.
And then go to the nodes section and click on the node we added.
Click on the launch button.
5.png
6.png
7.png
Select the below window and hold alt key to get the options enabled.
8
9.png
Click on refresh, so you can see the node added successfully.
10
Download document: Add windows node to jenkins

Enable or Disable projects in Jenkins

By default, you don’t have any option to enable/disable a job or project in Jenkins.
The default view will be like this.
1
If you observe, there is no disable/enable option.
To make it available, install the Extra Columns Plugin
Then create a new view of type “List View” and select your projects, then click on add column and select the below one.
2
This will give you a button to enable/disable the project in the view created.
2

Difference or Relation between Jenkins, Maven and Ant

Jenkins will use Maven and ANT for building the applications like ear,jar,etc.
Ant and Maven are Build tools which is used to build the applications by using the code. Selection of Maven and Ant depends up on the project code which is developed by Developer.

How to schedule a job at a particular time and only if any changes are there?

I have created a job to run the build process daily with jenkins. It includes.
1. to checkin the code at a particular time.
2. to compile the code.
3. create and installer.
It is running in the scheduled time daily.
Is there any way to add one more step in the start to check whether any changes in the number of commits from the gitub repo and if no changes then skip the process.
The answer to the above requirement will be fulfilled with the below option in Poll SCM.
Jenkins_3
You need the give the schedule as below:
00 7 * * *
Which will initiate the build at 7 am in the morning as per system timezone and will check for any changes to the source as with previous build.If no changes then it will skip the build for that day.

How to fix mail settings issue in Jenkins or Hudson

When you are trying to configure automatic mail notification in Jenkins.You need to follow below steps.
  1. Set System Admin e-mail address.
    Manage Jenkins link left side → Goto “Jenkins Location” section → System Admin e-mail Address.
  2. Set Mail server settings.
    Goto email Notification section down → enter below fields.
    SMTP server : smtp.office365.com
    check SMTP authentication checkbox and you will get below options enabled and need to fill as below.
    username(same email ID as above),password,smtp port(587)
  3. Click on apply/save.
To check the above configuration: check the “Test configuration by sending test e-mail” checkbox and provide the email ID in the entry enabled and click on “Test Configuration” button.
If you get any error like “mail client is not authenticated” then you need to enable TLS for Jenkins.
How to do that?
If you are using Jenkins on Linux then:
Open the file /etc/default/jenkins and add below text to it on a new line.
JAVA_ARGS=”-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true”
If it already had a variable with same name then append the value to the same variable inside the quotes.
If you are using Jenkins on Windows then:
You may have Jenkins installed with two options.
1. Jenkins war file running with Tomcat.
2. Jenkins war file running using “java -jar jenkins.war” command with command prompt.
3. Jenkins msi installed locally on the machine and there is a jenkins service installed.
For those people using the 3rd option:
Goto <C:\Program Files\Jenkins\> or <C:\Program Files\Jenkins-OC\>.Or program files (x86) if it is a 64-bit OS.And open the jenkins.xml file and goto the arguments tab and add the value there.
Below is the modified value as in my Jenkins machine:
I have added entry -Dmail.smtp.starttls.enable=true
<executable>%BASE%\jre\bin\java</executable>
  <arguments>-Dmail.smtp.starttls.enable=true -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
  

Jenkins issue with fetching GitHub Data

To operate GitHub based source code repositories in Jenkins.All you need to install the Git Plugin.
And below configurations are required.
1. Goto Manage Jenkins → Global Tool configuration. → Scroll to Git section and keep the Name as is and “Path to Git Location as just git.exe“. As we are going to keep the git.exe folder to the environment variable path.
2. While installing Git on your machine, don’t forget to uncheck the feature “Git credential manager”.
3. Once it is done create a free style project and add the github url to the source code management section in job configuration page by selecting the radio button git there.
jenkisn_1
Give values for below options.
Jenkins_2
When you try to build the project, you may get issues like timeout while fetching the github repo.
Like in the below post: Stackoverflow
The issue is because the git.exe is trying to access git credential manager for the credential support.All you need to do is to uninstall and reinstall again by uncheking the git credential manager sub feature.