Saturday, 3 October 2020

Jenkins job creation for CI/CD

Install the below plugins:

  1. Maven integration
  2. Test Results Analyzer
  3. testNG result 
  4. Role-based Authorization Strategy
  5. Deploy to container
  6. Develory Pipeline
  7. Docker ?
  8. Selenium HTML Report ?
  9. HTML publisher ?

********* Steps to Jenkins job to BUILD  using maven project  and GitHub Webhooks ************

Click Jenkins on top left and click New Items  -- > Enter your Project Name --> Select Maven Project only  and click  OK  --> Enter description 

Source Code Management :  >>  GIT  

>>  enter repository URL eg.   "https://github.com/ravindersanjay/jinkins-pipe.git"   

Build Triggers :  "GitHub Hook trigger for GITScm polling"

Build :  Root POM >> enter "MavenProjectName/POM.xml" file path taken from eclipse

>> Goals and options >> clean install

Post Steps : Run Regardless of build result. 

Add Post build actions :   Select Publish testNG results   --> Click Apply and SAVE


Steps to Convert local host URL to a public URL using ngrok

Steps of installation :

download the ngrok.exe file and put in a folder 

double click the ngrok.exe >> it will open CMD >> 

login to ngrok website and copy  below command from "connect to your command " section and paste in ngrok >> CMD

$ ngrok config add-authtoken TOKEN  ==> this is syntex 

eg.  $ ngrok config add-authtoken 2ApArYfh07t4Vubt98dfpBljYa8_2ecLcY6q1QcZ4cyQS6PyQ

$ ngrok http 8080


Lesson learned : 

1. if previous session is already running , kill that session from Task Manager

2. visit this url once "https://0046-122-177-106-0.in.ngrok.io/github-webhook/" and click visit button. this will remove warrning page for future. 

GitHub >> Project >> Setting >> Webhooks >> Payload URL  "https://0046-122-177-106-0.in.ngrok.io/github-webhook/" >>   content type = "application/json" >> Update webhook >> make some change in the code and commit. 




******** Steps to create job to run Selenium Test  using free style project  and local maven ********

Run selenium test through jenkins after build:

login to jenkins >> create a new job >> free style >>

build step>>  Execute windows batch command  ( windows)  >>  command are given below

d:

REM  take below path from project properties in eclipse

cd D:\My Documents\git\jinkins-pipe\jinkinsTest  

mvn clean test

echo Success


+++++++++++++++++++++++++++++++++++++++++++++++++++

 create a Jenkins job with below settings:










No comments:

Post a Comment