Devops Tutorial 26 - Jenkinsfile from Git SCM
What you will Learn:
Install ‘git’ plugin
Create GitHub repository and commit a new file
Create pipeline job
Install ‘git’ plugin
Install ‘git’ plugin in Jenkins
Important note: Restart Jenkins after installing plugin
Create GitHub repository and commit a new file
Login to your Github account
Click ‘New’ to create a new repository
Make a note of repository url: https://github.com/W2AGit/JenkinsPipelineAsACode
Click ‘creating a new file’ link that you see above
We can mention any file name in the above text field
Next go to the jenkins job that we had created in the previous tutorial, see below
Copy the above code snippet
Paste it in the file that we have created in Github, see below
At the bottom you would see ‘Commit new file’ button, see below
Click this button to commit the file
Create pipeline job
Next, create a new job in jenkins (type ‘Pipeline’)
Next come to the Pipeline section and click the ‘Definition’ dropdown
Select ‘Pipeline script from SCM’
Select ‘Git’ from SCM dropdown (Git would be shown only if you have installed the Git plugin)
Next enter repository url
No need to enter any credentials for public repository
Next mention branch as */main
Next mention the filename in the Script Path
Apply and Save
Build the project
Wait for the build to get complete
Once completed, you would see the stage view
You can see the logs. The logs tell that the project was built from SCM, see below
Thank you for reading!