Skip to content

Commit 90ae77b

Browse files
BUILD-9765 cleanup & aligment *-gradle *-maven
1 parent b122f87 commit 90ae77b

File tree

13 files changed

+256
-200
lines changed

13 files changed

+256
-200
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,12 @@ See also [`config-maven`](#config-maven) input environment variables.
288288

289289
### Outputs
290290

291-
| Output | Description |
292-
|------------------|---------------------------------------------------------------------------|
293-
| `BUILD_NUMBER` | The current build number. Also set as environment variable `BUILD_NUMBER` |
294-
| `deployed` | `true` if the build succeed and was supposed to deploy |
295-
| `artifact-paths` | Newline-separated list of artifact paths for provenance attestation |
291+
| Output | Description |
292+
|-------------------|---------------------------------------------------------------------------------------------------------------|
293+
| `project-version` | The project version with build number (after replacement). Also set as environment variable `PROJECT_VERSION` |
294+
| `BUILD_NUMBER` | The current build number. Also set as environment variable `BUILD_NUMBER` |
295+
| `deployed` | `true` if the build succeed and was supposed to deploy |
296+
| `artifact-paths` | Newline-separated list of artifact paths for provenance attestation |
296297

297298
### Output Environment Variables
298299

@@ -496,11 +497,11 @@ steps:
496497

497498
### Outputs
498499

499-
| Output | Description |
500-
|-------------------|-----------------------------------------------------------------------------------------------------------------|
501-
| `BUILD_NUMBER` | The current build number. Also set as environment variable `BUILD_NUMBER` |
500+
| Output | Description |
501+
|-------------------|-----------------------------------------------------------------------------------------------------------------------|
502+
| `BUILD_NUMBER` | The current build number. Also set as environment variable `BUILD_NUMBER` |
502503
| `current-version` | The project version set in gradle.properties (before replacement). Also set as environment variable `CURRENT_VERSION` |
503-
| `project-version` | The project version with build number (after replacement). Also set as environment variable `PROJECT_VERSION` |
504+
| `project-version` | The project version with build number (after replacement). Also set as environment variable `PROJECT_VERSION` |
504505

505506
### Output Environment Variables
506507

@@ -604,7 +605,6 @@ jobs:
604605

605606
| Input | Description | Default |
606607
|-----------------------------|-------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
607-
| `public` | Deprecated | Repository visibility |
608608
| `artifactory-deploy-repo` | Deployment repository | `sonarsource-private-qa` for private repositories, `sonarsource-public-qa` for public repos |
609609
| `artifactory-reader-role` | Suffix for the Artifactory reader role in Vault | `private-reader` for private repos, `public-reader` for public repos |
610610
| `artifactory-deployer-role` | Suffix for the Artifactory deployer role in Vault | `qa-deployer` for private repos, `public-deployer` for public repos |

build-gradle/action.yml

Lines changed: 60 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
---
22
name: Build Gradle
3-
description: GitHub Action to build, analyze, and deploy a Gradle project with SonarQube integration
3+
description: GitHub Action to build, analyze, and deploy a Gradle project
44
inputs:
5-
public:
6-
description: Deprecated. Use `artifactory-reader-role`, `artifactory-deployer-role`, and `artifactory-deploy-repo` instead.
7-
default: ${{ github.event.repository.visibility == 'public' && 'true' || 'false' }}
8-
artifactory-deploy-repo:
9-
description: Deployment repository. Defaults to `sonarsource-private-qa` for private repositories, and `sonarsource-public-qa` for
10-
public repositories.
11-
default: ''
12-
artifactory-reader-role:
13-
description: Suffix for the Artifactory reader role in Vault. Defaults to `private-reader` for private repositories,
14-
and `public-reader` for public repositories.
15-
default: ''
165
artifactory-deployer-role:
176
description: Suffix for the Artifactory deployer role in Vault. Defaults to `qa-deployer` for private repositories, and
187
`public-deployer` for public repositories.
198
default: ''
9+
artifactory-deploy-repo:
10+
description: Deployment repository. Defaults to `sonarsource-private-qa` for private repositories, and `sonarsource-public-qa` for
11+
public repositories.
12+
default: ''
2013
gradle-args:
2114
description: Additional arguments to pass to Gradle
2215
deploy:
@@ -28,52 +21,57 @@ inputs:
2821
skip-tests:
2922
description: Whether to skip running tests
3023
default: 'false'
31-
use-develocity:
32-
description: Whether to use Develocity for build tracking.
24+
sonar-platform:
25+
description: SonarQube primary platform (next, sqc-eu, sqc-us, or none). Use 'none' to skip sonar scans.
26+
default: next
27+
run-shadow-scans:
28+
description: If true, run SonarQube analysis on all three platforms (next, sqc-eu, sqc-us).
29+
If false, run analysis on the platform specified with sonar-platform.
3330
default: 'false'
34-
develocity-url:
35-
description: URL for Develocity
36-
default: https://develocity.sonar.build/
31+
provenance:
32+
description: Whether to generate provenance attestation for built artifacts
33+
default: 'false'
34+
provenance-artifact-paths:
35+
description: >-
36+
Relative paths of the artifacts for which to generate a provenance attestation (glob pattern).
37+
Default is collected from '*/build/libs/*', '*/build/distributions/*', and '*/build/reports/*'
38+
default: ''
39+
# Inputs passed to config-gradle
40+
working-directory:
41+
description: Relative path under github.workspace to execute the build in
42+
default: .
43+
artifactory-reader-role:
44+
description: Suffix for the Artifactory reader role in Vault. Defaults to `private-reader` for private repositories, and `public-reader`
45+
for public repositories.
46+
default: ''
3747
repox-url:
3848
description: URL for Repox
3949
default: https://repox.jfrog.io
4050
repox-artifactory-url:
4151
description: URL for Repox Artifactory API (overrides repox-url/artifactory if provided)
4252
default: ''
43-
sonar-platform:
44-
description: SonarQube variant (next, sqc-eu, sqc-us, or none). Use 'none' to skip sonar scans.
45-
default: next
46-
working-directory:
47-
description: Relative path under github.workspace to execute the build in
48-
default: .
49-
run-shadow-scans:
50-
description: If true, run sonar scanner on all 3 platforms using the provided URL and token.
51-
If false, run on the platform provided by SONAR_PLATFORM.
53+
use-develocity:
54+
description: Whether to use Develocity for build tracking.
5255
default: 'false'
56+
develocity-url:
57+
description: URL for Develocity
58+
default: https://develocity.sonar.build/
5359
cache-paths:
54-
description: Cache paths to use (multiline). If provided, overrides the default Gradle cache directories
60+
description: Cache paths to use (multiline).
5561
default: |-
5662
~/.gradle/caches
5763
~/.gradle/wrapper
5864
disable-caching:
5965
description: Whether to disable Gradle caching entirely
6066
default: 'false'
61-
provenance:
62-
description: Whether to generate provenance attestation for built artifacts
63-
default: 'false'
64-
provenance-artifact-paths:
65-
description: >-
66-
Relative paths of the artifacts for which to generate a provenance attestation (glob pattern).
67-
Default is collected from '*/build/libs/*', '*/build/distributions/*', and '*/build/reports/*'
68-
default: ''
6967

7068
outputs:
7169
project-version:
7270
description: The release version set as Gradle project version in gradle.properties
73-
value: ${{ steps.config-gradle.outputs.project-version }}
71+
value: ${{ steps.config.outputs.project-version }}
7472
BUILD_NUMBER:
7573
description: The build number, incremented or reused if already cached
76-
value: ${{ steps.config-gradle.outputs.BUILD_NUMBER }}
74+
value: ${{ steps.config.outputs.BUILD_NUMBER }}
7775
deployed:
7876
description: Whether artifacts were deployed
7977
value: ${{ steps.build.outputs.deployed }}
@@ -103,6 +101,19 @@ runs:
103101
ls -la .actions/*
104102
echo "::endgroup::"
105103
104+
- uses: ./.actions/config-gradle
105+
id: config
106+
with:
107+
host-actions-root: ${{ steps.set-path.outputs.host_actions_root }}
108+
working-directory: ${{ inputs.working-directory }}
109+
artifactory-reader-role: ${{ inputs.artifactory-reader-role }}
110+
repox-url: ${{ inputs.repox-url }}
111+
repox-artifactory-url: ${{ inputs.repox-artifactory-url }}
112+
use-develocity: ${{ inputs.use-develocity }}
113+
develocity-url: ${{ inputs.develocity-url }}
114+
cache-paths: ${{ inputs.cache-paths }}
115+
disable-caching: ${{ inputs.disable-caching }}
116+
106117
- name: Set build parameters
107118
shell: bash
108119
env:
@@ -128,38 +139,9 @@ runs:
128139
development/kv/data/sign key_id | SIGN_KEY_ID;
129140
# yamllint enable rule:line-length
130141

131-
- name: Setup environment for deployment
132-
shell: bash
133-
env:
134-
# Deployment secrets
135-
ARTIFACTORY_DEPLOY_USERNAME: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_DEPLOY_USERNAME }}
136-
ARTIFACTORY_DEPLOY_ACCESS_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_DEPLOY_ACCESS_TOKEN }}
137-
ARTIFACTORY_DEPLOY_REPO: ${{ inputs.artifactory-deploy-repo != '' && inputs.artifactory-deploy-repo ||
138-
github.event.repository.visibility == 'public' && 'sonarsource-public-qa' || 'sonarsource-private-qa' }}
139-
run: |
140-
echo "ARTIFACTORY_DEPLOY_USERNAME=$ARTIFACTORY_DEPLOY_USERNAME" >> "$GITHUB_ENV"
141-
echo "ARTIFACTORY_DEPLOY_ACCESS_TOKEN=$ARTIFACTORY_DEPLOY_ACCESS_TOKEN" >> "$GITHUB_ENV"
142-
echo "ARTIFACTORY_DEPLOY_PASSWORD=$ARTIFACTORY_DEPLOY_ACCESS_TOKEN" >> "$GITHUB_ENV" # deprecated, backward compliance
143-
echo "ARTIFACTORY_DEPLOY_REPO=${ARTIFACTORY_DEPLOY_REPO}" >> "$GITHUB_ENV"
144-
145-
- name: Configure Gradle
146-
uses: ./.actions/config-gradle
147-
id: config-gradle
148-
with:
149-
host-actions-root: ${{ steps.set-path.outputs.host_actions_root }}
150-
working-directory: ${{ inputs.working-directory }}
151-
artifactory-reader-role: ${{ inputs.artifactory-reader-role }}
152-
use-develocity: ${{ inputs.use-develocity }}
153-
develocity-url: ${{ inputs.develocity-url }}
154-
repox-url: ${{ inputs.repox-url }}
155-
repox-artifactory-url: ${{ inputs.repox-artifactory-url }}
156-
cache-paths: ${{ inputs.cache-paths }}
157-
disable-caching: ${{ inputs.disable-caching }}
158-
159142
- name: Build, analyze and deploy
160-
id: build
161143
shell: bash
162-
working-directory: ${{ inputs.working-directory }}
144+
id: build
163145
env:
164146
# GitHub context
165147
PULL_REQUEST: ${{ github.event.pull_request.number || '' }}
@@ -171,20 +153,24 @@ runs:
171153
DEPLOY_PULL_REQUEST: ${{ inputs.deploy-pull-request }}
172154
SKIP_TESTS: ${{ inputs.skip-tests }}
173155
GRADLE_ARGS: ${{ inputs.gradle-args }}
156+
SONAR_PLATFORM: ${{ inputs.sonar-platform }}
157+
RUN_SHADOW_SCANS: ${{ inputs.run-shadow-scans }}
158+
ARTIFACTORY_DEPLOY_REPO: ${{ inputs.artifactory-deploy-repo != '' && inputs.artifactory-deploy-repo ||
159+
github.event.repository.visibility == 'public' && 'sonarsource-public-qa' || 'sonarsource-private-qa' }}
174160

175-
# Vault secrets - always fetch all platforms
161+
# Vault secrets
162+
ARTIFACTORY_DEPLOY_USERNAME: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_DEPLOY_USERNAME }}
163+
ARTIFACTORY_DEPLOY_ACCESS_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_DEPLOY_ACCESS_TOKEN }}
176164
NEXT_URL: ${{ fromJSON(steps.secrets.outputs.vault).NEXT_URL }}
177165
NEXT_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).NEXT_TOKEN }}
178-
SQC_US_URL: ${{ fromJSON(steps.secrets.outputs.vault).SQC_US_URL }}
179-
SQC_US_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SQC_US_TOKEN }}
180166
SQC_EU_URL: ${{ fromJSON(steps.secrets.outputs.vault).SQC_EU_URL }}
181167
SQC_EU_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SQC_EU_TOKEN }}
182-
SONAR_PLATFORM: ${{ inputs.sonar-platform }}
183-
RUN_SHADOW_SCANS: ${{ inputs.run-shadow-scans }}
184-
168+
SQC_US_URL: ${{ fromJSON(steps.secrets.outputs.vault).SQC_US_URL }}
169+
SQC_US_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).SQC_US_TOKEN }}
185170
ORG_GRADLE_PROJECT_signingKey: ${{ fromJSON(steps.secrets.outputs.vault).SIGN_KEY }}
186171
ORG_GRADLE_PROJECT_signingPassword: ${{ fromJSON(steps.secrets.outputs.vault).PGP_PASSPHRASE }}
187172
ORG_GRADLE_PROJECT_signingKeyId: ${{ fromJSON(steps.secrets.outputs.vault).SIGN_KEY_ID }}
173+
working-directory: ${{ inputs.working-directory }}
188174
run: ${GITHUB_ACTION_PATH}/build.sh
189175

190176
- name: Archive problems report
@@ -194,6 +180,7 @@ runs:
194180
name: problems-report-${{ github.job }}${{ strategy.job-index }}
195181
path: build/reports/problems/problems-report.html
196182
if-no-files-found: ignore
183+
197184
- name: Generate provenance attestation
198185
if: >-
199186
${{ inputs.provenance == 'true' &&
@@ -209,9 +196,6 @@ runs:
209196
- name: Generate workflow summary
210197
if: always()
211198
shell: bash
212-
env:
213-
ARTIFACTORY_URL: ${{ inputs.repox-artifactory-url != '' && inputs.repox-artifactory-url ||
214-
format('{0}/artifactory', inputs.repox-url) }}
215199
run: |
216200
build_name="${GITHUB_REPOSITORY#*/}"
217201
echo "## 🏗️ Gradle Build Summary" >> $GITHUB_STEP_SUMMARY

build-gradle/build.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ get_build_type() {
186186

187187
set_gradle_cmd() {
188188
if [[ -f "./gradlew" ]]; then
189+
check_tool ./gradlew --version
189190
export GRADLE_CMD="./gradlew"
190-
elif check_tool gradle; then
191+
elif check_tool gradle --version; then
191192
export GRADLE_CMD="gradle"
192193
else
193194
echo "Neither ./gradlew nor gradle command found!" >&2
@@ -246,10 +247,11 @@ export_built_artifacts() {
246247

247248
# Find all built artifacts, excluding sources/javadoc/tests JARs
248249
local artifacts
249-
artifacts=$(/usr/bin/find . \( -path '*/build/libs/*' -o -path '*/build/distributions/*' -o -path '*/build/reports/*' \) \
250-
\( -name '*.jar' -o -name '*.war' -o -name '*.ear' -o -name '*.zip' -o -name '*.tar.gz' -o -name '*.tar' -o -name '*.json' \) \
251-
! -name '*-sources.jar' ! -name '*-javadoc.jar' ! -name '*-tests.jar' \
252-
-type f 2>/dev/null)
250+
local path_includes=(-path '*/build/libs/*' -o -path '*/build/distributions/*' -o -path '*/build/reports/*')
251+
local name_includes=(-name '*.jar' -o -name '*.war' -o -name '*.ear' -o -name '*.zip' -o -name '*.tar.gz' -o -name '*.tar')
252+
name_includes+=(-o -name '*.json')
253+
local name_excludes=(! -name '*-sources.jar' ! -name '*-javadoc.jar' ! -name '*-tests.jar')
254+
artifacts=$(/usr/bin/find . \( "${path_includes[@]}" \) \( "${name_includes[@]}" \) "${name_excludes[@]}" -type f 2>/dev/null)
253255

254256
# Sort and deduplicate (avoid Windows sort.exe)
255257
if [[ -n "$artifacts" ]]; then

0 commit comments

Comments
 (0)