- Notifications
You must be signed in to change notification settings - Fork 117
Improve Gradle version retrieval in Sentry workflow #3535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Update command to retrieve release version from Gradle.
WalkthroughA GitHub Actions workflow step for extracting version from Gradle is updated to execute with stricter flags ( Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/sentry.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: build (23, ubuntu-latest)
- GitHub Check: build (21, windows-latest)
- GitHub Check: build (23, windows-latest)
- GitHub Check: build (17, windows-latest)
- GitHub Check: build (21, ubuntu-latest)
- GitHub Check: build (21, macOS-latest)
- GitHub Check: build (17, ubuntu-latest)
- GitHub Check: build (17, macOS-latest)
- GitHub Check: Analyse
- GitHub Check: build (23, macOS-latest)
- GitHub Check: build (23, windows-latest)
- GitHub Check: build (21, windows-latest)
- GitHub Check: build (17, windows-latest)
- GitHub Check: build (17, macOS-latest)
- GitHub Check: build (21, ubuntu-latest)
- GitHub Check: build (21, macOS-latest)
- GitHub Check: build (23, ubuntu-latest)
- GitHub Check: build (17, ubuntu-latest)
- GitHub Check: build
- GitHub Check: Sentry
| - name: Get version from Gradle | ||
| id: get_version | ||
| run: echo "RELEASE_VERSION=$(./gradlew version --console plain -q)" >> $GITHUB_ENV | ||
| run: echo "RELEASE_VERSION=$(./gradlew version -q --console plain --no-daemon --warning-mode none 2>/dev/null | tail -1)" >> $GITHUB_ENV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Add error handling for Gradle version extraction.
The command suppresses all stderr (2>/dev/null) and pipes to tail -1, which silently masks failures. If ./gradlew version fails or produces no output, RELEASE_VERSION will be set to an empty string, causing downstream steps to fail in confusing ways without clear error messages.
Consider:
- Checking if the command succeeded before proceeding
- Validating that
RELEASE_VERSIONis non-empty and in the expected format - Using more targeted stderr filtering (if suppression is necessary) rather than discarding all diagnostics
Apply this diff to add basic error handling:
- run: echo "RELEASE_VERSION=$(./gradlew version -q --console plain --no-daemon --warning-mode none 2>/dev/null | tail -1)" >> $GITHUB_ENV + run: | + VERSION=$(./gradlew version -q --console plain --no-daemon --warning-mode none 2>&1 | tail -1) + if [ -z "$VERSION" ]; then + echo "ERROR: Failed to retrieve version from Gradle" >&2 + exit 1 + fi + echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENVAlternatively, if the full stderr is intentionally suppressed to hide build warnings, add a comment explaining why, and consider logging the extracted version for debugging.
--- 🏁 Script executed: ```shell #!/bin/bash # Examine the sentry workflow file around line 27 fd -name "sentry.yml" -path "*/.github/workflows/*" --exec cat {} \; Length of output: 230
🏁 Script executed:
#!/bin/bash # Search for RELEASE_VERSION usage in workflows rg -n "RELEASE_VERSION" .github/workflows/ -A 2 -B 2Length of output: 1399
🏁 Script executed:
#!/bin/bash # Check for error handling patterns in GitHub Actions workflows rg -n "set -e|exit 1|\$\?||| exit" .github/workflows/ --type yamlLength of output: 48481
Add error handling for Gradle version extraction to prevent silent failures.
The command suppresses all stderr (2>/dev/null) and pipes to tail -1, which silently masks failures. If ./gradlew version fails or produces no output, RELEASE_VERSION will be set to an empty string. This causes the subsequent conditionals (lines 31–35) to fail matching, silently defaulting to ENVIRONMENT=feature (line 38), and the Sentry release action to receive an invalid version.
Apply this diff to add validation:
- run: echo "RELEASE_VERSION=$(./gradlew version -q --console plain --no-daemon --warning-mode none 2>/dev/null | tail -1)" >> $GITHUB_ENV + run: | + VERSION=$(./gradlew version -q --console plain --no-daemon --warning-mode none 2>&1 | tail -1) + if [ -z "$VERSION" ]; then + echo "ERROR: Failed to retrieve version from Gradle" >&2 + exit 1 + fi + echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV🤖 Prompt for AI Agents
.github/workflows/sentry.yml around line 27: the current command hides all stderr and can produce an empty RELEASE_VERSION silently; change it to capture both stdout and stderr (don’t redirect stderr to /dev/null), assign the command output to a variable, trim and validate that it is non-empty and matches the expected version pattern, and if validation fails print an error to stdout/stderr and exit non‑zero so the workflow fails early; alternatively, set a clear fallback and log a warning before exiting to avoid passing an invalid empty RELEASE_VERSION to the Sentry action. |



Update command to retrieve release version from Gradle.
Описание
Связанные задачи
Closes
Чеклист
Общие
gradlew precommit)Для диагностик
Дополнительно
Summary by CodeRabbit