# jenkins / pipeline / practice

Jenkins Pipeline: SCM & Build

Today I successfully configured a Jenkins Pipeline project to automatically pull source code from GitHub (SCM) and execute a Build stage to prepare the application environment.

Build #1
Git PullSuccess
Repositoryiamshanmugananthan/jenkins
Build StageSuccess
StatusPipeline Completed
Declarative
Pipeline
main
Branch
# architecture

The Pipeline Flow

The core function of this pipeline is to establish a bridge between the version control system and the continuous integration server. The flow proceeds directly from SCM to Build.

task 1

Source Control Management (SCM)

Connected Jenkins directly to my GitHub repository. In this stage, Jenkins acts as a client, successfully cloning/downloading the latest project code from Git into its workspace.

task 2

The Build Stage

After pulling the code, the Build stage triggers. The purpose of this stage is to prepare the application environment by compiling source code, installing necessary dependencies, or building container images (e.g., using docker build -t myapp .).

# code

Jenkinsfile Configuration

This is the declarative pipeline script used to define the stages for this task. It instructs the Jenkins agent to checkout the code and then run a simple shell execution.

JenkinsfileGROOVY
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
pipeline {
    agent any
    
    stages {
        stage('SCM') {
            steps {
                git 'https://github.com/iamshanmugananthan/jenkins.git'
            }
        }
        stage('Build') {
            steps {
                sh 'echo Build Stage Running'
            }
        }
    }
}
# execution

Steps Followed

Authentication & Setup

  • 1. GitHub Auth

    Opened GitHub Developer Settings and created a new Personal Access Token (PAT) for secure connection.

  • 2. Jenkins Creds

    Navigated to Jenkins and securely stored that PAT into Jenkins Credentials.

  • 3. Create Project

    Created a brand new Jenkins Pipeline Project via the Jenkins dashboard.

Pipeline Integration

  • 4. Configure SCM

    In the SCM section of the pipeline, added the GitHub repository URL and selected the stored credentials.

  • 5. Set Branch

    Changed the branch specifier to target the main branch.

  • 6. Validate & Run

    Ensured the root of the repository contained the valid Jenkinsfile, saved the project, and clicked Build Now to run the pipeline successfully.