{"id":30501,"date":"2021-11-07T07:41:06","date_gmt":"2021-11-07T07:41:06","guid":{"rendered":"https:\/\/naiveskill.com\/?p=30501"},"modified":"2023-01-13T14:54:28","modified_gmt":"2023-01-13T14:54:28","slug":"jenkins-pipeline-github","status":"publish","type":"post","link":"https:\/\/naiveskill.com\/jenkins-pipeline-github\/","title":{"rendered":"Jenkins Pipeline github | Complete tutorial with example [2023]"},"content":{"rendered":"\n

This is the third part of the\u00a0Jenkins<\/a> pipeline example. In this blog, we will learn about Jenkins Pipeline github<\/strong>.<\/p>\n\n\n\n

Jenkins github plugin<\/h2>\n\n\n\n

It is important to understand the Github plugin before creating a Jenkins pipeline to pull the images from Github.<\/p>\n\n\n\n

The Jenkins GitHub plugin is a plugin for the Jenkins continuous integration server that allows Jenkins to interact with GitHub.using this plugin, Jenkins can automatically build, test, and deploy software changes from a GitHub repository.<\/p>\n\n\n\n

It can also trigger builds in Jenkins when changes are pushed to the GitHub repository. The github plugin is widely used by developers to integrate their software development workflow with Jenkins and GitHub.<\/p>\n\n\n\n

Jenkins Declarative Pipeline github example<\/h2>\n\n\n\n

In this session, we will clone <\/strong>the GitHub repository <\/strong>using the Jenkins pipeline script and run a bash script file to print hello world.<\/p>\n\n\n\n

To create a declarative pipeline in Jenkins, go to Jenkins UI and click on New item<\/strong>.<\/p>\n\n\n\n

Provide the pipeline name, select Pipeline, and click on the ok<\/strong> button.<\/p>\n\n\n\n

\"Jenkins<\/figure>\n\n\n\n

Now go to the pipeline session, paste the code below, and click on the Save<\/strong> button.<\/p>\n\n\n\n

pipeline {\n    agent any\n    stages {\n        stage('Build') {\n            steps {\n                \/\/ Get some code from a GitHub repository\n                git url: 'https:\/\/github.com\/naiveskill\/devops.git', branch: 'main'\n                \/\/ Change file permisson\n                sh \"chmod +x -R .\/jenkins\"\n                \/\/ Run shell script\n                sh \".\/jenkins\/script\/scripted_pipeline_ex_2.sh\"\n            }\n        }\n    }\n}<\/pre>\n\n\n\n
\"Jenkins<\/figure>\n\n\n\n

Code explanation<\/strong><\/p>\n\n\n\n

    \n
  1. Pipeline<\/strong>\n