Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 23, 2025

This PR implements comprehensive Git submodule support for the Codex Jenkinsfile pipeline, including proper commit ordering to maintain Git submodule semantics.

Problem

The current Jenkinsfile performs standard Git operations (git clone, git checkout, git reset) but doesn't handle Git submodules. When working with repositories that contain submodules, the pipeline would:

  • Successfully clone the main repository
  • Miss the submodule content (submodule directories would be empty)
  • Potentially fail when Codex tries to work with incomplete repository content
  • Even if submodules were initialized, changes within submodules wouldn't be properly committed

Solution

Added comprehensive Git submodule support with proper commit workflow:

New Parameter

  • ENABLE_SUBMODULES (boolean, defaults to false): When enabled, initializes and updates all Git submodules after repository checkout

Enhanced Pipeline Stages

Initialize Workspace:

  • Added submodule initialization logic that runs git submodule init and git submodule update --recursive when enabled
  • Positioned after git checkout/reset but before workspace cleanup to ensure submodules are properly populated

Check for Git Changes:

  • Enhanced change detection to show submodule status when submodules are enabled
  • Provides better visibility into submodule state changes made by Codex

Commit and Push Changes:

  • Proper commit ordering: When submodules are enabled, commits are processed in the correct order:
    1. First, iterates through all submodules and commits changes within each submodule repository
    2. Then commits the parent repository, which captures the updated submodule references
  • Individual submodule push support: Pushes submodule changes to their respective remotes when ENABLE_GIT_PUSH is enabled
  • Maintains Git submodule semantics: Ensures submodule reference updates are properly included as part of the parent commit

Key Features

  • Backwards Compatible: Default behavior unchanged - submodules are disabled by default
  • Recursive Updates: Uses --recursive flag to handle nested submodules
  • Safe Fallback: Git submodule commands work correctly even when no submodules exist
  • Enhanced Visibility: Shows submodule status alongside regular git status when changes are detected
  • Proper Git Semantics: Follows Git submodule best practices for commit ordering and reference management
  • Comprehensive Push Support: Handles pushing both submodule and parent repository changes

Usage

To enable submodule support, simply set the ENABLE_SUBMODULES parameter to true when running the pipeline. The pipeline will then:

  1. Initialize all submodules: git submodule init
  2. Update submodules recursively: git submodule update --recursive
  3. When changes are detected, commit submodule changes first, then parent repository
  4. Show submodule status when changes are detected
  5. Push both submodule and parent repository changes when ENABLE_GIT_PUSH is enabled

This ensures that repositories with submodules are fully populated before Codex operations begin, and that any changes made by Codex are properly committed with correct submodule reference updates.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: roryeckel <16675082+roryeckel@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Implement the necessary functionality to support submodules in the Jenkinsfile Add Git submodule support to Jenkinsfile Aug 23, 2025
@Copilot Copilot AI requested a review from roryeckel August 23, 2025 04:19
Copilot finished work on behalf of roryeckel August 23, 2025 04:19
@roryeckel
Copy link
Owner

@copilot It's not that simple - the final commit/push needs to occur for the submodules in a similar fashion to the existing logic before the parent project commits so the ref updates are properly added as a part of the commit

- Add submodule-specific commit logic before parent repository commits
- Iterate through submodules and commit changes within each submodule first
- Update parent repository to capture submodule reference updates
- Include submodule push support when ENABLE_GIT_PUSH is enabled
- Update documentation to reflect enhanced submodule handling

Co-authored-by: roryeckel <16675082+roryeckel@users.noreply.github.com>
Copy link
Author

Copilot AI commented Aug 23, 2025

@copilot It's not that simple - the final commit/push needs to occur for the submodules in a similar fashion to the existing logic before the parent project commits so the ref updates are properly add...

You're absolutely right! I've enhanced the implementation to handle proper commit ordering. The pipeline now:

  1. Commits submodule changes first: Iterates through each submodule, detects changes, and commits them within their respective repositories
  2. Commits parent repository with updated refs: After submodule commits, the parent repository is committed with the updated submodule references

This ensures submodule ref updates are properly included as part of the parent commit, maintaining correct Git submodule semantics.

Fixed in commit 7a7db69.

@Copilot Copilot AI changed the title Add Git submodule support to Jenkinsfile Add comprehensive Git submodule support with proper commit ordering to Jenkinsfile Aug 23, 2025
Copilot finished work on behalf of roryeckel August 23, 2025 04:35
@roryeckel
Copy link
Owner

Needs testing

@roryeckel roryeckel requested a review from Copilot August 25, 2025 02:39
Copilot

This comment was marked as resolved.

@roryeckel roryeckel requested a review from Copilot August 25, 2025 04:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive Git submodule support to the Jenkinsfile pipeline with proper commit ordering to maintain Git submodule semantics. When enabled via the new ENABLE_SUBMODULES parameter, the pipeline will initialize and update all submodules recursively, handle change detection for submodule content, and commit changes in the correct order (submodules first, then parent repository).

  • Added ENABLE_SUBMODULES boolean parameter (defaults to false) for backward compatibility
  • Enhanced pipeline stages to support submodule initialization, change detection, and proper commit ordering
  • Implemented submodule-aware git operations including individual submodule pushing when changes are detected

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
README.md Documents the new submodule feature, parameter, and updated pipeline behavior
Jenkinsfile Implements submodule initialization, enhanced change detection, and proper commit ordering logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants