Git + Jenkins

To integrate Git with Jenkins, follow these steps:

  1. Install the Git plugin:

    • Access the Jenkins web interface.

    • Click on "Manage Jenkins" in the left-hand side menu.

    • Select "Manage Plugins" from the dropdown.

    • Navigate to the "Available" tab.

    • Search for "Git" in the filter box.

    • Check the box next to "Git Plugin".

    • Click on the "Install without restart" button.

  2. Configure global Git settings:

    • Go back to the Jenkins dashboard.

    • Click on "Manage Jenkins" in the left-hand side menu.

    • Select "Global Tool Configuration" from the dropdown.

    • Scroll down to the "Git" section.

    • Click on "Git installations...".

    • Click on the "Add Git" button.

    • Provide a name for the Git installation (e.g., "Default Git").

    • Specify the path to the Git executable (e.g., "git").

    • Click on the "Save" button.

  3. Create a new Jenkins job:

    • On the Jenkins dashboard, click on "New Item" on the left-hand side.

    • Enter a name for your job and select "Freestyle project".

    • Click "OK" to proceed.

  4. Configure the job:

    • Source Code Management: In the job configuration page, under the "Source Code Management" section, select "Git".

    • Repository URL: Enter the URL of your Git repository.

    • Credentials: If your repository requires authentication, click on the "Add" button to add your Git credentials.

    • Branches to build: Specify the branch you want Jenkins to build (e.g., */master).

    • Additional Git options: Add any additional Git options, such as submodules or shallow clone settings.

    • Save the job configuration.

  5. Build the job:

    • On the Jenkins dashboard, click on the job name to navigate to its details page.

    • Click on "Build Now" to trigger the build.

Jenkins will now clone the Git repository specified in the job configuration, and you can perform various build steps and actions on the source code. You can configure additional build steps, such as running tests, building artifacts, or deploying the application.

Last updated