DevOps/Cloud By GK
  • DevOps/Cloud Introduction
  • 🚩AWS
    • Create AWS Account
    • Launch EC2 Instance
  • 🚩Linux
    • User Managment
      • Adding the User to Sudo group
      • visudo
    • Directory / File Management
      • Vi
      • Changing Permissions (chmod)
      • Filtering IO/File
    • Memory Management
    • Process Management
    • Network Management
    • Service Management
    • Environmental Variables
      • $PATH
    • Utilities
    • SHELL PROGRAMMING
      • Hello World
      • Variables
      • Command Line arguments
      • Conditional Statements
      • Array
      • Loops
      • Functions
      • AWK
      • sed
      • Example Useful Scripts
      • Basic -> Advanced
  • 🚩git
    • Introduction
    • Creating GitHub Account
    • Installation
      • Git Bash In Windows
      • Git In VS Code
      • Git In Eclipse
      • Git CLI in Linux
  • Creating Git Remote Repository
  • Git Commands L -> R
  • Git Commands L <- R
  • Git Branch Commands
  • Using SSH (Password Less)
  • 🚩maven
    • Introduction
    • Installation
    • POM.xml
    • Goals
  • 🚩SonarQube
    • Introduction
    • Sonar Cloud
    • Creating Project In SonarCloud
    • Installing Sonar-Scanner
    • Triggering Scan
  • 🚩Nexus
    • Introduction
    • Installation of Nexus
    • Creating Repository
    • Uploading Artifacts to Repository
  • 🚩Jenkins
    • Introduction
    • Installation of Jenkins
    • First Job In Jenkins
    • Git + Jenkins
      • WebHook
    • Maven + Jenkins
    • Sonar-Scanner + Jenkins
    • Nexus + Jenkins
Powered by GitBook
On this page
  1. Jenkins
  2. Git + Jenkins

WebHook

To create a webhook to trigger a Jenkins job when a push event happens in your Git repository, follow these steps:

  1. Access the Jenkins web interface.

  2. Open the configuration page for the Jenkins job you want to trigger.

  3. Under the job configuration, click on the "Build Triggers" section.

  4. Check the "GitHub hook trigger for GITScm polling" option.

    Note: The exact wording may differ depending on the version of Jenkins or the plugin you are using. Look for an option that mentions triggering builds via a Git webhook or polling.

  5. Save the job configuration.

  6. Obtain the Jenkins job URL.

    • On the job details page, copy the URL from the browser's address bar.

  7. Go to your Git repository settings.

    • Navigate to the repository settings or options page in your Git hosting platform (e.g., GitHub, GitLab, Bitbucket).

  8. Look for the "Webhooks" or "Hooks" section in the repository settings.

  9. Add a new webhook.

    • Click on the "Add webhook" or similar button to create a new webhook.

  10. Configure the webhook settings.

    • Paste the Jenkins job URL you copied earlier into the "Payload URL" or "Endpoint URL" field.

    • Select the event that should trigger the webhook. In this case, choose "Push" or "Push event".

    • Optionally, you can configure other webhook settings, such as the content type or SSL verification.

  11. Save the webhook.

    • Click on the "Save" or "Add webhook" button to save the webhook configuration.

  12. Test the webhook.

    • Make a test push to your Git repository, either by committing and pushing changes or using a dummy commit.

    • Check the Jenkins job details page to verify if the webhook triggered the build.

Now, whenever a push event occurs in your Git repository, the webhook will send a request to the Jenkins job's URL, triggering a build. You can view the build status, logs, and other details in the Jenkins job details page.

Please note that the webhook configuration may vary depending on the Git hosting platform you are using. The steps mentioned here are general guidelines, and you may need to adapt them to the specific settings and options provided by your chosen Git hosting platform.

PreviousGit + JenkinsNextMaven + Jenkins

Last updated 2 years ago

🚩