{"id":184,"date":"2021-02-16T15:25:57","date_gmt":"2021-02-16T07:25:57","guid":{"rendered":"https:\/\/www.linyinghao.cn\/wordpress\/?p=184"},"modified":"2022-02-04T22:55:13","modified_gmt":"2022-02-04T14:55:13","slug":"integrate-git-maven-and-jenkins-to-automate-selenium-testing","status":"publish","type":"post","link":"https:\/\/www.linyinghao.cn\/wordpress\/?p=184","title":{"rendered":"Integrate Git, Maven and Jenkins to Automate Selenium Testing"},"content":{"rendered":"\n<p>Integration of Git, Maven and Jenkins provides capability of auto triggering Linux shell or Windows batch scripts to instantly test the newly pushed code or data in Git repository. This article is listing the detail configuration steps of each component for the purpose. The whole architecture is:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-4-1024x612.png\" alt=\"\" class=\"wp-image-175\" width=\"580\" height=\"346\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-4-1024x612.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-4-300x179.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-4-768x459.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-4.png 1198w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/figure>\n\n\n\n<p>This whole solution can be deployed in most mainstream OS including Linux, Windows and MacOS. It is assumes JKD has already been installed in the machine. In this demo, Oracle JDK 1.8 has been used.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.linyinghao.cn\/wordpress\/?p=184\/#Configure_Maven\" >Configure Maven<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.linyinghao.cn\/wordpress\/?p=184\/#Install_Jenkins\" >Install Jenkins<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.linyinghao.cn\/wordpress\/?p=184\/#Configure_Jenkins\" >Configure Jenkins<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.linyinghao.cn\/wordpress\/?p=184\/#Create_Jenkins_Job\" >Create Jenkins Job<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.linyinghao.cn\/wordpress\/?p=184\/#Configure_Github\" >Configure Github<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.linyinghao.cn\/wordpress\/?p=184\/#Trigger_Jenkins_Job_from_Web_Service\" >Trigger Jenkins Job from Web Service<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"configure-maven\"><span class=\"ez-toc-section\" id=\"Configure_Maven\"><\/span>Configure Maven<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Configure Maven is as easy as two steps:<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<ol class=\"wp-block-list\"><li>Download Maven from <a href=\"https:\/\/maven.apache.org\/download.cgi\" data-type=\"URL\" data-id=\"https:\/\/maven.apache.org\/download.cgi\">https:\/\/maven.apache.org\/download.cgi<\/a>. Current up-to-date version is 3.6.3. Download the Binary zip archive to local driver and  unzip it.<\/li><li>Add Maven executable files in environment variable PATH. In Windows, add Maven bin directory into Path. In Linux or MacOS, append the Maven bin directory in path variable in ~\/.bash_profile.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"548\" height=\"347\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-8.png\" alt=\"\" class=\"wp-image-189\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-8.png 548w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-8-300x190.png 300w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><\/a><figcaption>Windows Setup<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code># Linux setup\npath = path:\/apache-maven-3.6.3\/bin<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>Verify if mvn command can be recognized in command window.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-9.png\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"115\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-9.png\" alt=\"\" class=\"wp-image-190\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-9.png 703w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-9-300x49.png 300w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/a><figcaption>Verify command mvn in Windows<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"104\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-10.png\" alt=\"\" class=\"wp-image-191\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-10.png 736w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-10-300x42.png 300w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/a><figcaption>Verify command mvn in Linux<\/figcaption><\/figure>\n\n\n\n<p><\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"install-jenkins\"><span class=\"ez-toc-section\" id=\"Install_Jenkins\"><\/span>Install Jenkins<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>Download Jenkins from <a href=\"https:\/\/www.jenkins.io\/download\" data-type=\"URL\" data-id=\"https:\/\/www.jenkins.io\/download\">https:\/\/www.jenkins.io\/download<\/a>. Current up-to-date LTS version is 2.2263.4. The most simple way to run it is to use the Generic Java package jenkins.war. Download it to local driver.<\/li><li>Run jenkins.war using following command<\/li><\/ol>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-code\"><code># Run Jenkins using Java\njava -jar jenkins.war<\/code><\/pre>\n<\/div><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"173\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-11-1024x173.png\" alt=\"\" class=\"wp-image-193\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-11-1024x173.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-11-300x51.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-11-768x130.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-11.png 1410w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>When Jenkins is running for the first time, admin password is generated and visible from console:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" width=\"729\" height=\"232\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-12.png\" alt=\"\" class=\"wp-image-194\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-12.png 729w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-12-300x95.png 300w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><\/a><\/figure>\n\n\n\n<p>Copy it and open a browser to login to default address <a href=\"http:\/\/localhost:8080\" data-type=\"URL\" data-id=\"http:\/\/localhost:8080\">http:\/\/localhost:8080<\/a>. Past the default password and unlock Jenkins:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"700\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-13.png\" alt=\"\" class=\"wp-image-195\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-13.png 1000w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-13-300x210.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-13-768x538.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><\/figure>\n\n\n\n<p>Either install recommended Jenkins plugins, or manually choose required plugins. Here we choose recommended plugins, and wait for all plugin installed:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-14.png\"><img loading=\"lazy\" decoding=\"async\" width=\"999\" height=\"701\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-14.png\" alt=\"\" class=\"wp-image-196\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-14.png 999w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-14-300x211.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-14-768x539.png 768w\" sizes=\"auto, (max-width: 999px) 100vw, 999px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-15.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1003\" height=\"702\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-15.png\" alt=\"\" class=\"wp-image-198\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-15.png 1003w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-15-300x210.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-15-768x538.png 768w\" sizes=\"auto, (max-width: 1003px) 100vw, 1003px\" \/><\/a><\/figure>\n\n\n\n<p>Register new admin user for Jenkins:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1001\" height=\"700\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-16.png\" alt=\"\" class=\"wp-image-199\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-16.png 1001w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-16-300x210.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-16-768x537.png 768w\" sizes=\"auto, (max-width: 1001px) 100vw, 1001px\" \/><\/a><\/figure>\n\n\n\n<p>Keep the default login URL or change it as per preference, and finish:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-17.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1001\" height=\"702\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-17.png\" alt=\"\" class=\"wp-image-200\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-17.png 1001w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-17-300x210.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-17-768x539.png 768w\" sizes=\"auto, (max-width: 1001px) 100vw, 1001px\" \/><\/a><\/figure>\n\n\n\n<p>Make sure there is no problem to login to Jenkins with admin user:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-18.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"470\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-18-1024x470.png\" alt=\"\" class=\"wp-image-201\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-18-1024x470.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-18-300x138.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-18-768x352.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-18.png 1417w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configure-jenkins\"><span class=\"ez-toc-section\" id=\"Configure_Jenkins\"><\/span>Configure Jenkins<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>Manage Global Tool Configuration<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-19.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"353\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-19-1024x353.png\" alt=\"\" class=\"wp-image-202\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-19-1024x353.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-19-300x103.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-19-768x264.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-19.png 1417w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Configure JDK with JAVA_HOME and Name<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-20.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"521\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-20-1024x521.png\" alt=\"\" class=\"wp-image-203\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-20-1024x521.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-20-300x153.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-20-768x390.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-20.png 1418w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>Manage Credentials. Because Jenkins need to fetch and pull data from Git repository, it needs the credential to access Github. To access Github, it is recommended to use SSH key which has higher security level. Here in the credential management page, choose &#8220;SSH Username with private Key&#8221; as credential kind, and manually input private key content in the Key area. SSH key can be generated using this guide: <a href=\"https:\/\/docs.github.com\/en\/enterprise-server@2.21\/github\/authenticating-to-github\/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent\" data-type=\"URL\" data-id=\"https:\/\/docs.github.com\/en\/enterprise-server@2.21\/github\/authenticating-to-github\/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent\">https:\/\/docs.github.com\/en\/enterprise-server@2.21\/github\/authenticating-to-github\/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent<\/a>. By default, private key is named as id_rsa, and it is exactly which we need here. The other file id_rsa.pub is public key which is required later when we configuring Git repository.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-22.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"375\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-22-1024x375.png\" alt=\"\" class=\"wp-image-205\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-22-1024x375.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-22-300x110.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-22-768x281.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-22.png 1419w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-24.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"470\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-24-1024x470.png\" alt=\"\" class=\"wp-image-207\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-24-1024x470.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-24-300x138.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-24-768x353.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-24.png 1417w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>Manage Users<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-25.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"502\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-25-1024x502.png\" alt=\"\" class=\"wp-image-208\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-25-1024x502.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-25-300x147.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-25-768x376.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-25.png 1420w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-26.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"263\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-26-1024x263.png\" alt=\"\" class=\"wp-image-210\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-26-1024x263.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-26-300x77.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-26-768x197.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-26.png 1435w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Add and generate new API token for user. This is necessary if Jenkins job is designed to be auto triggered from Git web hook.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-27.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"369\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-27-1024x369.png\" alt=\"\" class=\"wp-image-211\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-27-1024x369.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-27-300x108.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-27-768x277.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-27.png 1422w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Markdown the token somewhere as it will be used in Git web hook definition, and save it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-28.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"524\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-28-1024x524.png\" alt=\"\" class=\"wp-image-212\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-28-1024x524.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-28-300x154.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-28-768x393.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-28.png 1420w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"create-jenkins-job\"><span class=\"ez-toc-section\" id=\"Create_Jenkins_Job\"><\/span>Create Jenkins Job<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This is the core setup of continuous integration among Git, Jenkins, Maven and Selenium. Jenkins job is created to be auto triggered by Git push, and then it coordinates Maven build, package, and testing execution.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-29.png\"><img loading=\"lazy\" decoding=\"async\" width=\"352\" height=\"436\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-29.png\" alt=\"\" class=\"wp-image-213\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-29.png 352w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-29-242x300.png 242w\" sizes=\"auto, (max-width: 352px) 100vw, 352px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-30.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"521\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-30-1024x521.png\" alt=\"\" class=\"wp-image-214\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-30-1024x521.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-30-300x153.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-30-768x391.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-30.png 1403w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Provide repository URL of Selenium Automation repository, provide credential of what we just created, and choose the Git repository branch which we want to monitor:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-31.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"558\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-31-1024x558.png\" alt=\"\" class=\"wp-image-215\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-31-1024x558.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-31-300x163.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-31-768x418.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-31.png 1204w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Following 3 checkbox are optional.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Checking the box for &#8220;Trigger builds remotely&#8221; enables the job to be triggered from web service.<\/li><li>Checking the box for &#8220;Build periodically&#8221; enables the job to be scheduled and executed at regular interval.<\/li><li>Checking the box for &#8220;GitHub hook trigger for GITScm polling&#8221; enables the job auto triggered from Github. However, in this case Jenkins must has a public network URL so that Github can reach Jenkins, otherwise it won&#8217;t be working.<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-41.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"542\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-41-1024x542.png\" alt=\"\" class=\"wp-image-227\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-41-1024x542.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-41-300x159.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-41-768x406.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-41.png 1244w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Add following windows batch commands to execute Maven build, package as well as Selenium testing execution. In Linux there are equivalent shell commands to perform the same operations.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>REM Copy the files pulled from Git repository, and move then to another folder maven for build\nxcopy \/E \/Y C:\\Users\\clark\\.jenkins\\workspace\\SeleniumAutomationExecutionJob\\SeleniumAutomation c:\\Users\\clark\\maven\\SeleniumAutomation\\\n\nREM Change directory to maven folder\ncd c:\\Users\\clark\\maven\\SeleniumAutomation\n\nREM Maven build\nmvn clean install package<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>REM Change directory to packaged Selenium testing JAR file\ncd c:\\Users\\clark\\maven\\SeleniumAutomation\\target\nchdir\n\nREM Execute Selenium testing\njava -jar SeleniumAutomation-0.0.1-SNAPSHOT-jar-with-dependencies.jar<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-35.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"599\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-35-1024x599.png\" alt=\"\" class=\"wp-image-220\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-35-1024x599.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-35-300x176.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-35-768x450.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-35.png 1440w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Build it manually to ensure configuration is correct:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-36.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"344\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-36-1024x344.png\" alt=\"\" class=\"wp-image-221\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-36-1024x344.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-36-300x101.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-36-768x258.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-36.png 1413w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Click build number to go into specific Jenkins build:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-37.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1012\" height=\"614\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-37.png\" alt=\"\" class=\"wp-image-222\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-37.png 1012w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-37-300x182.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-37-768x466.png 768w\" sizes=\"auto, (max-width: 1012px) 100vw, 1012px\" \/><\/a><\/figure>\n\n\n\n<p>Click Console Output to monitor the execution progress:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-39.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"425\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-39-1024x425.png\" alt=\"\" class=\"wp-image-224\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-39-1024x425.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-39-300x124.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-39-768x318.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-39.png 1030w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Ensure maven build succeed and Selenium testing is executed:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-40.png\"><img loading=\"lazy\" decoding=\"async\" width=\"899\" height=\"390\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-40.png\" alt=\"\" class=\"wp-image-225\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-40.png 899w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-40-300x130.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-40-768x333.png 768w\" sizes=\"auto, (max-width: 899px) 100vw, 899px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configure-github\"><span class=\"ez-toc-section\" id=\"Configure_Github\"><\/span>Configure Github<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure-public-key\">Configure Public Key<\/h3>\n\n\n\n<p>To enable access from Jenkins, public key need to be registered in Github. Click user icon at right top and choose Settings:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"215\" height=\"404\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-50.png\" alt=\"\" class=\"wp-image-239\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-50.png 215w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-50-160x300.png 160w\" sizes=\"auto, (max-width: 215px) 100vw, 215px\" \/><\/figure>\n\n\n\n<p>Click &#8220;SSH and GPG keys&#8221; and then &#8220;New SSH Key&#8221;. This should be the public key id_rsa.pub generated in previous step.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"421\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-53-1024x421.png\" alt=\"\" class=\"wp-image-242\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-53-1024x421.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-53-300x123.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-53-768x316.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-53.png 1427w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"configure-web-hook\">Configure Web Hook<\/h3>\n\n\n\n<p>If Jenkins has public network URL, then the job can be triggered by Github web hook. To enable web hook, go to Github repository setting page:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-42.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"202\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-42-1024x202.png\" alt=\"\" class=\"wp-image-228\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-42-1024x202.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-42-300x59.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-42-768x152.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-42.png 1220w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Go to Hooks tab and Add webhook:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-43.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"450\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-43-1024x450.png\" alt=\"\" class=\"wp-image-229\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-43-1024x450.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-43-300x132.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-43-768x338.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-43.png 1278w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Payload URL is public URL of Jenkins with fixed suffix &#8220;github-webhook&#8221;. Content type can be left as default. Secret the the API token which has been generated in previous Manage User step in Jenkins configuration. By default, web hook is configured for Git push event, but it can be customized as per individual requirement.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-44.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"621\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-44-1024x621.png\" alt=\"\" class=\"wp-image-230\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-44-1024x621.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-44-300x182.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-44-768x466.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-44.png 1227w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>If every thing is fine, try perform a new push to the repository monitored by Jenkins job. Web hook is auto triggered after Git push:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-55.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"456\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-55-1024x456.png\" alt=\"\" class=\"wp-image-252\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-55-1024x456.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-55-300x134.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-55-768x342.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-55.png 1442w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Here we are using another Jenkins instance hosted in public network to finish the POC. In Jenkins job GitHub Hook Log, verify Jenkins has received the web hook. In this case, it doesn&#8217;t detect new push, so the build is not triggered. If there is new push detected, the job will be executed automatically.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-54.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"529\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-54-1024x529.png\" alt=\"\" class=\"wp-image-251\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-54-1024x529.png 1024w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-54-300x155.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-54-768x397.png 768w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-54-1536x793.png 1536w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-54-1170x606.png 1170w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-54.png 1928w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"trigger-jenkins-job-from-web-service\"><span class=\"ez-toc-section\" id=\"Trigger_Jenkins_Job_from_Web_Service\"><\/span>Trigger Jenkins Job from Web Service<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In case Jenkins is located in local area network and not directly reachable from Github, an alternative way to trigger the Jenkins job from external system is to use web service.<\/p>\n\n\n\n<p>To simply demo this operation, use command line tool curl to call Jenkins web service:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -u clark:&lt;User API Token&gt; localhost:8080\/job\/SeleniumAutomationExecutionJob\/build?token=&lt;Jenkins Job Token&gt;<\/code><\/pre>\n\n\n\n<p>In this script, &lt;User API Token&gt; is what has been generated in previous Manage User step in Jenkins configuration. &lt;Jenkins Job Token&gt; is what has been defined in Authentication Token in job Build Triggers definition. Specifically in this case, the whole command is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -u clark:112d97bd86d72a38450e04318d5dbf4166 http:\/\/localhost:8080\/job\/SeleniumAutomationExecutionJob\/build?token=SeleniumAutomationExecutionJobToken<\/code><\/pre>\n\n\n\n<p>Verify Jenkins job is triggered remotely from LAN:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-49.png\"><img loading=\"lazy\" decoding=\"async\" width=\"972\" height=\"482\" src=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-49.png\" alt=\"\" class=\"wp-image-235\" srcset=\"https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-49.png 972w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-49-300x149.png 300w, https:\/\/www.linyinghao.cn\/wordpress\/wp-content\/uploads\/2021\/02\/image-49-768x381.png 768w\" sizes=\"auto, (max-width: 972px) 100vw, 972px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This article describes step by step configurations to build continuous integration of Automation Testing solution.<\/p>\n","protected":false},"author":1,"featured_media":843,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[8,7,5,6,4],"class_list":["post-184","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-2","tag-automation","tag-git","tag-jenkins","tag-maven","tag-selenium"],"_links":{"self":[{"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=184"}],"version-history":[{"count":12,"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":859,"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/184\/revisions\/859"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=\/wp\/v2\/media\/843"}],"wp:attachment":[{"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linyinghao.cn\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}