-
Go to Jenkins Dashboard.
-
Create a New Job:
- Click New Item.
- Enter a name for your pipeline (e.g.,
GroovyPipelineFromGitHub
). - Select Pipeline as the job type and click OK.
-
Configure the Pipeline Job:
- In the configuration page, scroll down to the Pipeline section.
- Set Definition to Pipeline script from SCM (Source Control Management).
- Set SCM to Git.
- In the Repository URL, enter the URL of your GitHub repository (e.g.,
https://github.com/<your-username>/jenkins-pipeline-demo.git
).
-
Credentials:
- If your repository is private, add your GitHub credentials by clicking Add → Jenkins, then enter your GitHub username and password or token.
-
Branch:
- By default, Jenkins uses the
master
branch. You can specify another branch if needed.
- By default, Jenkins uses the
-
Script Path:
- Ensure that the Script Path is set to
Jenkinsfile
(if your file is named something else, specify that here).
- Ensure that the Script Path is set to
-
Save the Job.
-
Run the Job:
- On the job's page, click Build Now to trigger the pipeline.
-
Check Build Progress:
- You will see the build in the Build History section on the left.
- Click the build number to view the progress and output.
-
Console Output:
- Check the Console Output to see each stage of the pipeline as it executes:
- Apache (
httpd
) installation. - Status check.
- Success message indicating the website is live.
- Apache (
- Check the Console Output to see each stage of the pipeline as it executes:
-
Update Jenkinsfile in GitHub:
- You can modify the
Jenkinsfile
in your GitHub repository to add more stages, steps, or logic.
- You can modify the
-
Trigger the Job Automatically:
- To automatically trigger the Jenkins job when you push changes to GitHub, you can configure a Webhook in GitHub under Settings → Webhooks.