How to use Source Code Management in Jenkins Pipeline

Viewed 3035

I want to whenever I start the Jenkins pipeline build, the job will either clone/pull from the Git.

But I don't know how to do this in Jenkins Pipeline, besides hard coding git clone $url , git pull (if exists) in one of the early steps of the first stage.

1 Answers

This is pipeline configuration and Jenkins will do the magic. You just need to create a Pipeline Task and in Configuration in the Pipeline section, select your SCM and put your repo URL.

enter image description here

When you perform a build, Jenkins will pull and checkout the code.

Hope it helps.

Related