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.
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.
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.
In the script, we have created three steps, for that we need to check the logs for those three steps
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.