Jenkinsfile from Git SCM

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!

Share On

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Share on tumblr
Share on email

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Lifetime Membership Club

LIFETIME MEMBERSHIP BIG SALE - ALL LIVE COURES JUST - 7000 RS/ 99 USD
Attend All Live courses in just 7000 rs / $99 - offer ends 1st Nov 2024