Showing posts with label Jenkins. Show all posts
Showing posts with label Jenkins. Show all posts

Sunday, June 19, 2016

2 Steps to restrict Jenkins access by IP address or Host Name



Steps to fresh jenkins installtion on on Apache Tomcat Server : http://www.automatethebox.com/2016/06/installing-jenkins-on-apache-tomcat.html

If Jenkins is installed on Tomcat Server 

  1.  Add any of the below entry in the conf\context.xml file :
    • <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1"/><!--Allow from Ip Address-->
    • <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="127.0.0.1"/><!--Deny from Ip Address-->
    • <Valve className="org.apache.catalina.valves.RemoteHostValve" allow="yahoo.com"/><!--Allow from a Domain-->
    • <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|202.43.25.244"/><!--Allow from multipl ip's-->
  2.  Restart the Tomcat Server
Now, when you try to access Jenkins url, you should get 403 error

If Jenkins is installed on Apache Server 

  1. Add all of the below entries in the conf\.htaccess file to allow access from ip '45.67.87.67' and '10.66.62.0/24' LAN only
    • Order Deny,Allow
    • Deny from all
    • Allow from 45.67.87.67
    • Allow from 10.66.62.0/24
  2. Restart the Apache Server

Now, when you try to access Jenkins url, you should get 403 error




Installing Jenkins on Apache Tomcat Server


First of all if you have not installed the Apache Tomcat Server, We will be going to install it on Windows following the below steps :
  • Download the Apache Server from Url :  http://www.apache.org/dyn/closer.cgi

  • Extract the Tomcat zip folder
  • Navigate to to 'conf' directory, path may be somewhat like '..\apache-tomcat-9.0.0.M8\conf' from where you have extracted the zip.
  • Open the Server.xml file and edit the PORT where you want the Tomcat to listen for the requests

  • Now start Command Prompt and go to '..\apache-tomcat-9.0.0.M8\bin' and call 'startup.bat'
  • Now start a browser and navigate to url '<your_system_ip:port_specified_in_step4>'. Example : 127.0.0.1:8080
    • You should see Tomcat Successfully installed page. Congratulation!


Now, we will be moving to next part of configuring Jenkins behind the Tomcat Server  :
  •  Download Jenkins.war file from https://jenkins.io/
  • Once downloaded, unzip and move the jenkins.war to directory '.\apache-tomcat-9.0.0.M8\webapps'
  • Restart the Tomcat. CTRL+C or call the .\apache-tomcat-9.0.0.M8\bin\shutdown.bat' and then start again.
    • Now when you navigate to 127.0.0.1/jenkins, you should see jenkins successfully installed.

Feel free to leave comments !!!

Sunday, December 20, 2015

Configure Jenkins email notifications

In this tutorial we will discuss about setting up the email notification in your Jenkins environment from the start :

Part I: Configure the email notifications from Jenkins Management section.

Part II : Configure the email notification for the individual Jenkins job  

Part I: Configure the email notifications from Jenkins Management section.

  1. First you should be logged in to Jenkins interface as Administrators, so you should see 'Manage Jenkins' link on the left side options.
  2. Click on the 'Manage Jenkins', to navigate to 'Manage Jenkins' page. 'Configure System' option should be available
  3. Click on the 'Configure System' link, scroll down on 'Configure System' page, you should see the 'Email notifications' section.
  4. Set the following settings in the 'Email notification' section [We are taking yahoo domain for example]
    • SMTP Server : smtp.mail.yahoo.com
    • Check 'Use SMTP Authentication'
    • Username : <email address to send emails> Example : test@yahoo.com
    • Password : <used email address password>
    • Check 'Use SSL'
    • SMTP Port : 465
    • Reply-To-Address :  <email address to reply emails, can be same email or different>
    • Charset : UTF-8
    • Scroll up on the page and now set following settings in 'Locations' section
      • System admin e-mail address :  <email address to send emails> Example : test@yahoo.com
    • Now to test your email configurations, Scroll down to 'Email Notification' section.
      • Check 'Test Configuration by sending test e-mail'
      • Test e-mail recipient : <recipient email address to test configuration> Example: youremail@yahoo.com
      • Click on "Test Configuration" button.
    • You should see message 'Email was successfully sent'. It yes, congrats you have successfully configured Jenkins email notifications :)
    • 'Apply' and 'Save' the changes.

    Part II : Configure the email notification for the individual Jenkins job  

    1. Navigate to configuration page of Jenkins job, for which you wants to send a email notification. For example we have a job 'test-email-notification'
    2. Under 'Post Build Actions', click on 'Add post build action' and select 'Email Notification' option.
    3. Now, when the 'Email notification' section visible. Provide the recipients email addresses and select other check box options per your requirement
    4. Click on Apply and Save the changes.
    Feel free to leave your comments in case of any issues in above steps... :)

    Thursday, October 31, 2013

    Use environment variable in Jenkins editable email notification subject.

    Today, i am gonna describe a solution to send the Jenkins email notification with editable subject instead of default subject each time depending upon the current environment variable.
                                                                                                     This can help you in the case when you have a Jenkins build,which builds with user provided environment variable according to requirement and then you may also want to get the email notification after completion with the subject having environment variable used to trigger build.

    I assume you have created a Jenkins job as per your project requirements :

    Step 1 : Configure the build parameters [ User defined environment variable ]
    For Example


    Step 2 : Add Editable email notification as after build action  :


    Step 3 : Update the Default subject as given in screenshot to include the user given environment variables in email notification.
    For Example
    If you have user defined parameter 'testsite' with value 'automatethebox.blogspot.com', then to send the parameter value in email notification update the default subject field as :
    ${ENV, var="testsite"}




    Step 4 : Save the job configuration and its ready to go :)

    AWS Certified Solutions Architect Associate - AWS Introduction - Questions

    All the Best !!! Show Result !! Try Again !! ×