Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

feat(attachments): add attachment management commands#60

Merged
piekstra merged 4 commits intomainfrom
piekstra/58-attachment-support
Jan 29, 2026
Merged

feat(attachments): add attachment management commands#60
piekstra merged 4 commits intomainfrom
piekstra/58-attachment-support

Conversation

@piekstra
Copy link
Copy Markdown
Collaborator

@piekstra piekstra commented Jan 29, 2026

[#58]

Add full attachment management support for Jira issues.

Summary

  • Add jtk attachments list <issue-key> - List all attachments on an issue
  • Add jtk attachments add <issue-key> --file <path> - Upload file attachments
  • Add jtk attachments get <attachment-id> - Download attachment by ID
  • Add jtk attachments delete <attachment-id> - Delete attachment by ID

Usage

# List attachments on an issue
jtk attachments list PROJ-123

# Add attachment(s)
jtk attachments add PROJ-123 --file document.pdf
jtk attachments add PROJ-123 --file doc.pdf --file screenshot.png

# Download attachment
jtk attachments get 12345 --output ./downloads/

# Delete attachment
jtk attachments delete 12345

API Layer

  • GetIssueAttachments - List attachments via issue fields
  • GetAttachment - Get attachment metadata
  • AddAttachment - Upload with multipart/form-data and X-Atlassian-Token header
  • DeleteAttachment - Remove attachment
  • DownloadAttachment - Stream content to file
  • FormatFileSize - Human-readable file sizes
  • FlexibleID - Handle Jira API inconsistency where IDs are sometimes strings, sometimes numbers

Integration Tests

Added integration test infrastructure for testing against real Jira API:

# Run attachment integration tests
JIRA_TEST_PROJECT=PROJ JIRA_TEST_ISSUE_TYPE=Task \
  go test -tags=integration ./integration/... -run TestAttachments

Tests cover:

  • Full flow: add → list → get → download → delete
  • Multiple file uploads
  • Error cases (invalid issue, invalid ID, nonexistent file)

See integration/README.md for documentation.

Test plan

  • All existing unit tests pass
  • Lint passes
  • Command help works correctly
  • Integration tests pass against real Jira API
  • Manual testing: upload, list, download, delete all work

Closes #58

[#58]

- Add `jtk attachments list <issue-key>` to list issue attachments
- Add `jtk attachments add <issue-key> --file <path>` to upload attachments
- Add `jtk attachments get <attachment-id>` to download attachments
- Add `jtk attachments delete <attachment-id>` to delete attachments

API layer includes:
- GetIssueAttachments - list attachments on an issue
- GetAttachment - get attachment metadata by ID
- AddAttachment - upload file with multipart/form-data
- DeleteAttachment - remove attachment by ID
- DownloadAttachment - download attachment content

Closes #58
[#58] Jira API returns attachment IDs as numbers in some endpoints
but strings in others. Added FlexibleID type that handles both.
[#58] Added integration tests that verify attachment functionality against
real Jira API. Tests cover:
- Full flow: add → list → get → download → delete
- Multiple file uploads
- Error cases (invalid issue, invalid ID, nonexistent file)

Integration tests use build tags and skip automatically when credentials
are not configured. Run with:
  JIRA_TEST_PROJECT=PROJ JIRA_TEST_ISSUE_TYPE=Task \
    go test -tags=integration ./integration/...

Includes:
- integration/README.md - Documentation for running tests
- integration/helpers_test.go - Shared test utilities
- integration/attachments_test.go - Attachment-specific tests
@piekstra piekstra merged commit d60ffa0 into main Jan 29, 2026
2 checks passed
@piekstra piekstra deleted the piekstra/58-attachment-support branch January 29, 2026 21:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attachment support

1 participant