Step-by-Step Guide: Creating Declarative Pipelines in Jenkins Using SCM

Jenkins pipeline Using SCM:                      In the Previous Blog , we executed the Jenkins pipeline directly from the Jenkins build job...


Jenkins pipeline Using SCM:
                 In the Previous Blog, we executed the Jenkins pipeline directly from the Jenkins build job, but we have another method that is mostly used in the pipelines called pipeline using SCM.

SCM = Source Code management.

For Source code management, We can use any source code management tools, for our part, we are using GitHub. we have one pipeline job already so I am using the same pipeline job for SCM.

To configure the SCM, we need to click configure options inside my pipeline job.

Our pipeline job scrolls down until the pipeline option. you can able to see the pipeline section.
In the pipeline section, we can able see the two options, one is Pipeline, which is already completed, check our blog for Fist pipeline using the basic pipeline script.

  

The second option is the Pipeline script from SCM. so now I choose the second option. Once clicked the option it shows the SCM, In the SCM you need to choose Git. Here you need to add the repository and credentials.




After entering the repo and credentials scroll down you will see the Branch specifier option, here we need to give the branch. The branch we specify is going to use for the particular repo. 

By default, it has */master, In Github, we don't have a master branch now, Instead of the master we have the main branch so change as main in the configuration.

After updating the branch scroll down you will see the script path.
Here we need to add our script file name, For example, I have created the script as a Jenkins file. txt, so I used the same file here.

Now I have created the Jenkins file locally so I commit and push the file to the GitHub repo.
My Jenkinsfile script was updated in the Github repo.

Once all the above steps are completed. click the build now button, wait for two minutes for build status.

Once the build was successful you click build id and see the build logs. 
For the pipeline dashboard itself, we can able to see the build logs. .



In the script, we have created three steps, for that we need to check the logs for those three steps
For the second step, I gave simple echo build command.

echo 'Building...'

          echo "Running ${env.BUILD_ID} ${env.BUILD_DISPLAY_NAME} on ${env.NODE_NAME} and JOB ${env.JOB_NAME}" In the second step, it shows the build-id, env build’s display name and env node, and job name.




Now we have executed the Jenkins pipeline using SCM. In the same way, we can add our application on it to build using any build tools like Maven, ant and deploy it on Dockers.



----------------------------------------!!!! Happy Learning with Techiev !!!!!!!!---------------------------------

-------------------------Subscribe our Youtube Channel by clicking the below link---------------------- ----------------------------!!https://www.youtube.com/@techieview729!!---------------------




Name

AWS,14,Devops,24,linux,10,
ltr
item
Techie View: Step-by-Step Guide: Creating Declarative Pipelines in Jenkins Using SCM
Step-by-Step Guide: Creating Declarative Pipelines in Jenkins Using SCM
https://blogger.googleusercontent.com/img/a/AVvXsEj8I7NeMS8vXi6NqZdqfBmVVzoPW_ZcXjGHh-MHe5yXJJSgyU-ndzU9UU0iuvVamMWivfJf9pPT4vhKLVa0lumxdI3bc0lR4Kf6tyj2NS6I-2q22NKKGC25Z7E7wqx9PxtWcBZ3iD_edt7TXb9SmEwNgp8zmN5TVqi6-zHqrtuMpucNHfBkOZn7fPjuoA=w400-h160
https://blogger.googleusercontent.com/img/a/AVvXsEj8I7NeMS8vXi6NqZdqfBmVVzoPW_ZcXjGHh-MHe5yXJJSgyU-ndzU9UU0iuvVamMWivfJf9pPT4vhKLVa0lumxdI3bc0lR4Kf6tyj2NS6I-2q22NKKGC25Z7E7wqx9PxtWcBZ3iD_edt7TXb9SmEwNgp8zmN5TVqi6-zHqrtuMpucNHfBkOZn7fPjuoA=s72-w400-c-h160
Techie View
https://www.techiev.com/2022/03/jenkins-pipeline-using-scm-previous.html
https://www.techiev.com/
https://www.techiev.com/
https://www.techiev.com/2022/03/jenkins-pipeline-using-scm-previous.html
true
7013663511659419322
UTF-8
Loaded All Posts Not found any posts VIEW ALL View Full Article Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy