|
| 1 | +import {Fragment} from 'react'; |
| 2 | + |
| 3 | +import {CodeBlock} from './codeBlock'; |
| 4 | +import {GradleFeatureConfig} from './gradleFeatureConfig'; |
| 5 | +import {OrgAuthTokenNote} from './orgAuthTokenNote'; |
| 6 | + |
| 7 | +type Props = { |
| 8 | + feature: 'sizeAnalysis' | 'distribution'; |
| 9 | +}; |
| 10 | + |
| 11 | +export function GradleUploadInstructions({feature}: Props) { |
| 12 | + const featureName = feature === 'sizeAnalysis' ? 'size analysis' : 'distribution'; |
| 13 | + |
| 14 | + return ( |
| 15 | + <Fragment> |
| 16 | + <p> |
| 17 | + The Gradle plugin automatically detects build metadata from your git |
| 18 | + repository. On GitHub Actions, all metadata is automatically detected. On other |
| 19 | + CI systems, you may need to manually set some values using the{' '} |
| 20 | + <code>vcsInfo</code> extension. |
| 21 | + </p> |
| 22 | + |
| 23 | + <ol> |
| 24 | + <li> |
| 25 | + Configure the{' '} |
| 26 | + <a href="/platforms/android/configuration/gradle/"> |
| 27 | + Sentry Android Gradle plugin |
| 28 | + </a>{' '} |
| 29 | + with at least version <code>6.0.0-beta1</code> |
| 30 | + </li> |
| 31 | + |
| 32 | + <li> |
| 33 | + <p> |
| 34 | + Set the auth token as an environment variable to be used when running your |
| 35 | + release build. |
| 36 | + </p> |
| 37 | + <OrgAuthTokenNote /> |
| 38 | + <CodeBlock language="bash"> |
| 39 | + <pre> |
| 40 | + <code className="language-bash">{`export SENTRY_AUTH_TOKEN=___ORG_AUTH_TOKEN___`}</code> |
| 41 | + </pre> |
| 42 | + </CodeBlock> |
| 43 | + </li> |
| 44 | + |
| 45 | + <li> |
| 46 | + <p>Enable uploading for {featureName} for CI builds.</p> |
| 47 | + <GradleFeatureConfig feature={feature} /> |
| 48 | + </li> |
| 49 | + |
| 50 | + <li> |
| 51 | + <p> |
| 52 | + Invoke the following Gradle tasks to build your app and trigger the upload. |
| 53 | + </p> |
| 54 | + <CodeBlock language="bash" filename="aab"> |
| 55 | + <pre> |
| 56 | + <code className="language-bash">{`./gradlew bundleRelease`}</code> |
| 57 | + </pre> |
| 58 | + </CodeBlock> |
| 59 | + <CodeBlock language="bash" filename="apk"> |
| 60 | + <pre> |
| 61 | + <code className="language-bash">{`./gradlew assembleRelease`}</code> |
| 62 | + </pre> |
| 63 | + </CodeBlock> |
| 64 | + </li> |
| 65 | + |
| 66 | + <li> |
| 67 | + <p> |
| 68 | + After an upload has successfully processed, confirm the metadata is correct |
| 69 | + in the Sentry UI |
| 70 | + </p> |
| 71 | + <img |
| 72 | + src="/platforms/android/build-distribution/images/android-metadata.png" |
| 73 | + alt="Upload metadata" |
| 74 | + style={{maxWidth: '400px'}} |
| 75 | + /> |
| 76 | + </li> |
| 77 | + </ol> |
| 78 | + |
| 79 | + <h3>Overriding Metadata</h3> |
| 80 | + |
| 81 | + <p> |
| 82 | + The Gradle plugin automatically detects build metadata from your git |
| 83 | + repository. On GitHub Actions, all metadata is automatically detected. On other |
| 84 | + CI systems, you may need to manually set some values using the{' '} |
| 85 | + <code>vcsInfo</code> extension. |
| 86 | + </p> |
| 87 | + |
| 88 | + <p>Configure overrides in your Gradle build configuration:</p> |
| 89 | + |
| 90 | + <CodeBlock language="kotlin" filename="build.gradle.kts"> |
| 91 | + <pre> |
| 92 | + <code className="language-kotlin">{`sentry { |
| 93 | + ${feature} { |
| 94 | + enabled = providers.environmentVariable("GITHUB_ACTIONS").isPresent |
| 95 | + } |
| 96 | +
|
| 97 | + vcsInfo { |
| 98 | + headSha.set("abc123") |
| 99 | + baseSha.set("def456") |
| 100 | + vcsProvider.set("github") |
| 101 | + headRepoName.set("organization/repository") |
| 102 | + baseRepoName.set("organization/repository") |
| 103 | + headRef.set("feature-branch") |
| 104 | + baseRef.set("main") |
| 105 | + prNumber.set(42) |
| 106 | + } |
| 107 | +}`}</code> |
| 108 | + </pre> |
| 109 | + </CodeBlock> |
| 110 | + |
| 111 | + <CodeBlock language="groovy" filename="build.gradle"> |
| 112 | + <pre> |
| 113 | + <code className="language-groovy">{`sentry { |
| 114 | + ${feature} { |
| 115 | + enabled = providers.environmentVariable("GITHUB_ACTIONS").present |
| 116 | + } |
| 117 | +
|
| 118 | + vcsInfo { |
| 119 | + headSha = 'abc123' |
| 120 | + baseSha = 'def456' |
| 121 | + vcsProvider = 'github' |
| 122 | + headRepoName = 'organization/repository' |
| 123 | + baseRepoName = 'organization/repository' |
| 124 | + headRef = 'feature-branch' |
| 125 | + baseRef = 'main' |
| 126 | + prNumber = 42 |
| 127 | + } |
| 128 | +}`}</code> |
| 129 | + </pre> |
| 130 | + </CodeBlock> |
| 131 | + |
| 132 | + <p> |
| 133 | + Available <code>vcsInfo</code> properties: |
| 134 | + </p> |
| 135 | + |
| 136 | + <table> |
| 137 | + <thead> |
| 138 | + <tr> |
| 139 | + <th>Property</th> |
| 140 | + <th>Type</th> |
| 141 | + <th>Description</th> |
| 142 | + </tr> |
| 143 | + </thead> |
| 144 | + <tbody> |
| 145 | + <tr> |
| 146 | + <td> |
| 147 | + <code>headSha</code> |
| 148 | + </td> |
| 149 | + <td>String</td> |
| 150 | + <td>Current commit SHA</td> |
| 151 | + </tr> |
| 152 | + <tr> |
| 153 | + <td> |
| 154 | + <code>baseSha</code> |
| 155 | + </td> |
| 156 | + <td>String</td> |
| 157 | + <td>Base commit SHA (for comparison)</td> |
| 158 | + </tr> |
| 159 | + <tr> |
| 160 | + <td> |
| 161 | + <code>vcsProvider</code> |
| 162 | + </td> |
| 163 | + <td>String</td> |
| 164 | + <td>VCS provider (e.g., "github")</td> |
| 165 | + </tr> |
| 166 | + <tr> |
| 167 | + <td> |
| 168 | + <code>headRepoName</code> |
| 169 | + </td> |
| 170 | + <td>String</td> |
| 171 | + <td>Repository name (org/repo format)</td> |
| 172 | + </tr> |
| 173 | + <tr> |
| 174 | + <td> |
| 175 | + <code>baseRepoName</code> |
| 176 | + </td> |
| 177 | + <td>String</td> |
| 178 | + <td>Base repository name</td> |
| 179 | + </tr> |
| 180 | + <tr> |
| 181 | + <td> |
| 182 | + <code>headRef</code> |
| 183 | + </td> |
| 184 | + <td>String</td> |
| 185 | + <td>Branch or tag name</td> |
| 186 | + </tr> |
| 187 | + <tr> |
| 188 | + <td> |
| 189 | + <code>baseRef</code> |
| 190 | + </td> |
| 191 | + <td>String</td> |
| 192 | + <td>Base branch name</td> |
| 193 | + </tr> |
| 194 | + <tr> |
| 195 | + <td> |
| 196 | + <code>prNumber</code> |
| 197 | + </td> |
| 198 | + <td>Int</td> |
| 199 | + <td>Pull request number</td> |
| 200 | + </tr> |
| 201 | + </tbody> |
| 202 | + </table> |
| 203 | + </Fragment> |
| 204 | + ); |
| 205 | +} |
0 commit comments