Skip to content

Conversation

dt-atmosic
Copy link
Collaborator

@dt-atmosic dt-atmosic commented Sep 1, 2025

This PR implements issue #32 by adding new tools for artifact management and optimizing the getBuild response size.

New Tools Added

  1. getBuildArtifacts - Returns only the artifacts array from a build
    o Takes jobFullName and optional buildNumber parameters
    o Significantly reduces payload size compared to full getBuild response
    o Returns empty array for jobs without artifacts or non-existent jobs
    o Fixed JSON concatenation issue for top-level lists

  2. getBuildArtifact - Provides paginated access to individual artifact file contents
    o Supports offset/limit parameters for large files
    o Returns artifact content as text with pagination metadata
    o Includes safety limits to prevent excessive memory usage

Optimizations

  1. Modified getBuild response - Now excludes artifacts field
    o Created RunWithoutArtifactsSerializer to filter out artifacts
    o Updated JenkinsExportedBeanSerializerModifier to use custom serializer
    o Maintains all other build information while reducing response size

Testing done

  1. Comprehensive test coverage
    o BuildArtifactsExtensionTest - Integration tests for new tools
    o GetBuildWithoutArtifactsTest - Verifies getBuild optimization
    o BuildArtifactsExtensionCompileTest - Basic compilation verification

  2. Manual test
    o Augment Code MCP client w/ mvn hpi:run - Found JSON issue with top-level list
    o Manual test with Augment Code and production Jenkins server

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

dt-atmosic and others added 6 commits August 31, 2025 01:12
- Add BuildArtifactsExtension with getBuildArtifacts and getBuildArtifact tools
- Create RunWithoutArtifactsSerializer to exclude artifacts from getBuild responses
- Add comprehensive tests for new functionality
- Implement pagination support for large artifact files
- Maintain backward compatibility while reducing payload sizes

Addresses first part of issue jenkinsci#32: separate artifacts retrieval from build metadata
- Replace Java record with regular class for Java 11 compatibility
- Fix regex pattern in RunWithoutArtifactsSerializer with DOTALL flag
- Update test methods to use proper McpSchema.TextContent pattern
- Remove non-existent TestUtils.getTextContent() method calls
- Follow existing test patterns from the codebase
- Declare ObjectMapper inside lambda scope where it's used
- Resolves compilation error in GetBuildWithoutArtifactsTest.java
- Use record for BuildArtifactResponse
- Use TreePruner
- spotless:apply
@dt-atmosic dt-atmosic marked this pull request as ready for review October 20, 2025 23:20
@dt-atmosic dt-atmosic requested a review from a team as a code owner October 20, 2025 23:20
@dt-atmosic
Copy link
Collaborator Author

Working on the code coverage warnings.

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.

1 participant