Skip to content

Commit 733c141

Browse files
julien-carsique-sonarsourcesonartech
authored andcommitted
BUILD-9723 fix public & private artifacts deployment
GitOrigin-RevId: a5d4d1c821845ffeedc29d089899dd441a731770
1 parent a6b08a6 commit 733c141

5 files changed

Lines changed: 81 additions & 56 deletions

File tree

.github-commons/actions/analyze/action.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ inputs:
77
sonar-project-key:
88
description: 'SonarQube project key'
99
required: true
10-
build-number:
11-
description: 'Build number for analysis'
12-
required: true
1310

1411
runs:
1512
using: 'composite'
@@ -53,10 +50,9 @@ runs:
5350
SONAR_TOKEN: ${{ fromJson(steps.secrets.outputs.vault).SONAR_TOKEN }}
5451
SONAR_HOST_URL: ${{ steps.sonar-config.outputs.sonar_host_url }}
5552
SONAR_PROJECT_KEY: ${{ inputs.sonar-project-key }}
56-
BUILD_NUMBER: ${{ inputs.build-number }}
5753
GIT_SHA1: ${{ github.sha }}
5854
GITHUB_REPO: ${{ github.repository }}
5955
GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
6056
GITHUB_BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
6157
PULL_REQUEST: ${{ github.event.pull_request.number || 'false' }}
62-
PIPELINE_ID: ${{ inputs.build-number }}
58+
PIPELINE_ID: ${{ env.BUILD_NUMBER }}
Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,41 @@
11
name: 'Build Sonar Python'
22
description: 'Build both public and private modules of sonar-python'
3-
outputs:
4-
build-number:
5-
description: 'The build number used'
6-
value: ${{ steps.config.outputs.build-number }}
3+
74
runs:
85
using: 'composite'
96
steps:
107
- name: Configure sonar-python project
118
uses: ./.github/actions/config-sonar-python
12-
id: config
13-
with:
14-
build-number: ${{ inputs.build-number }}
159

16-
- name: Build public module with maven
17-
uses: SonarSource/ci-github-actions/build-maven@7fea21c7155e8f0d5d429c1af625d851a6fadc3d # master, 13.10.2025
10+
- name: Build public and private modules
11+
uses: SonarSource/ci-github-actions/build-maven@f1d7e9107578478801454495c63078f85f9f5615 # 1.2.1-BUILD-9723
12+
id: build
1813
with:
19-
artifactory-deploy-repo: "sonarsource-public-qa"
20-
maven-args: "-DskipTests=true -Dsonar.skip=true -P-typeshed_serializer"
14+
artifactory-deploy-repo: 'sonarsource-public-qa'
15+
maven-args: '-DskipTests=true -Dsonar.skip=true -P-typeshed_serializer -Dartifactory.publish.artifacts=false'
2116
deploy-pull-request: true
2217
sonar-platform: none
18+
cache-cleanup: false
19+
20+
- uses: SonarSource/vault-action-wrapper@320bd31b03e5dacaac6be51bbbb15adf7caccc32 # 3.1.0
21+
id: secrets
22+
with:
23+
secrets: |
24+
development/artifactory/token/{REPO_OWNER_NAME_DASH}-public-deployer access_token | ARTIFACTORY_DEPLOY_ACCESS_TOKEN;
25+
development/artifactory/token/{REPO_OWNER_NAME_DASH}-qa-deployer access_token | ARTIFACTORY_PRIVATE_DEPLOY_ACCESS_TOKEN;
26+
- name: Artifacts upload
27+
shell: bash
2328
env:
24-
IS_COMMUNITY: true
25-
BUILD_NUMBER: ${{ steps.config.outputs.build-number }}
29+
ARTIFACTORY_DEPLOY_REPO: 'sonarsource-public-qa'
30+
ARTIFACTORY_PRIVATE_DEPLOY_REPO: 'sonarsource-private-qa'
31+
ARTIFACTORY_DEPLOY_ACCESS_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_DEPLOY_ACCESS_TOKEN }}
32+
ARTIFACTORY_PRIVATE_DEPLOY_ACCESS_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_PRIVATE_DEPLOY_ACCESS_TOKEN }}
33+
INSTALLED_ARTIFACTS: ${{ steps.build.outputs.installed-artifacts }}
34+
run: ${GITHUB_ACTION_PATH}/deploy-artifacts.sh
2635

27-
- name: Remove .actions folder and make repository shallow for next steps
36+
- name: Cleanup Maven repository before caching
2837
shell: bash
2938
run: |
30-
echo "Making repository shallow"
31-
# BUILD-9065 will fix this, making this step redundant
32-
# git pull fails because we're not on a branch, but it still makes the repo shallow again
33-
git pull --depth 1 || true
34-
35-
# This step is needed because build-maven removes the .m2 folder, removing the built jar files of the public modules.
36-
# This re-builds the public modules so the private modules will find them.
37-
# See BUILD-9394 for details
38-
echo "Build public module with maven as build-maven cleans up after itself"
39-
IS_COMMUNITY=true mvn install -DskipTests -DskipTypeshed
40-
41-
- name: Build private module with maven
42-
uses: SonarSource/ci-github-actions/build-maven@7fea21c7155e8f0d5d429c1af625d851a6fadc3d # master, 13.10.2025
43-
with:
44-
artifactory-deploy-repo: "sonarsource-private-qa"
45-
maven-args: "-DskipTests=true -Dsonar.skip=true -P-typeshed_serializer"
46-
deploy-pull-request: true
47-
working-directory: private
48-
sonar-platform: none
49-
env:
50-
BUILD_NUMBER: ${{ steps.config.outputs.build-number }}
51-
MAVEN_ARGS: "-Dsonar.skip=true"
39+
rm -rf "$MAVEN_CONFIG/repository/org/sonarsource/"
40+
rm -rf "$MAVEN_CONFIG/repository/com/sonarsource/"
41+
/usr/bin/find "$MAVEN_CONFIG/repository" -name resolver-status.properties -delete
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# Deploy to public and private Artifactory repositories using JFrog CLI
3+
#
4+
# Required environment variables:
5+
# - ARTIFACTORY_URL: URL to Artifactory repository. Set by 'build-maven'.
6+
# - ARTIFACTORY_DEPLOY_REPO: Repository to deploy public artifacts.
7+
# - ARTIFACTORY_DEPLOY_ACCESS_TOKEN: Access token to deploy to public repository.
8+
# - ARTIFACTORY_PRIVATE_DEPLOY_REPO: Repository to deploy private artifacts
9+
# - ARTIFACTORY_PRIVATE_DEPLOY_ACCESS_TOKEN: Access token to deploy to private repository
10+
# - INSTALLED_ARTIFACTS: Artifacts produced by Maven and installed in the local repository.
11+
# - MAVEN_CONFIG: Path to the Maven configuration directory (typically $HOME/.m2). Set by 'build-maven'.
12+
13+
set -euo pipefail
14+
15+
: "${ARTIFACTORY_URL:?}" "${INSTALLED_ARTIFACTS:?}" "${MAVEN_CONFIG:?}"
16+
: "${ARTIFACTORY_DEPLOY_REPO:?}" "${ARTIFACTORY_DEPLOY_ACCESS_TOKEN:?}"
17+
: "${ARTIFACTORY_PRIVATE_DEPLOY_REPO:?}" "${ARTIFACTORY_PRIVATE_DEPLOY_ACCESS_TOKEN:?}"
18+
19+
public_artifacts=()
20+
private_artifacts=()
21+
for artifact in $INSTALLED_ARTIFACTS; do
22+
if [[ $artifact == "org/"* ]]; then
23+
public_artifacts+=("$artifact")
24+
elif [[ $artifact == "com/"* ]]; then
25+
private_artifacts+=("$artifact")
26+
else
27+
echo "WARN: Unrecognized artifact path: $artifact" >&2
28+
fi
29+
done
30+
31+
# TODO BUILD-9723 review this function
32+
extract_module_names() {
33+
artifact=$1
34+
module=$(echo "$artifact" | sed -E "s,^([^/]+/[^/]+/([^/]+))/([^/]+)/(([0-9].)+[0-9]+)/.*$,\1:\3:\4," | sed "s,/,.,g")
35+
echo "$module"
36+
}
37+
38+
build_name="${GITHUB_REPOSITORY#*/}"
39+
pushd "$MAVEN_CONFIG/repository"
40+
jfrog config add deploy --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_DEPLOY_ACCESS_TOKEN"
41+
jfrog config use deploy
42+
echo "Deploying public artifacts..."
43+
for artifact in "${public_artifacts[@]}"; do
44+
module=$(extract_module_names "$artifact")
45+
jfrog rt u --module "$module" --build-name "$build_name" --build-number "$BUILD_NUMBER" "$artifact" "${ARTIFACTORY_DEPLOY_REPO}"
46+
done
47+
echo "Deploying private artifacts..."
48+
jfrog config edit deploy --artifactory-url "$ARTIFACTORY_URL" --access-token "$ARTIFACTORY_PRIVATE_DEPLOY_ACCESS_TOKEN"
49+
for artifact in "${private_artifacts[@]}"; do
50+
module=$(extract_module_names "$artifact")
51+
jfrog rt u --module "$module" --build-name "$build_name" --build-number "$BUILD_NUMBER" "$artifact" "${ARTIFACTORY_PRIVATE_DEPLOY_REPO}"
52+
done
53+
popd
Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
name: 'Config Sonar Python'
22
description: 'Configure maven and update versions for sonar-python project'
3-
inputs:
4-
build-number:
5-
description: 'Build number to use for versioning. If not provided, will use the build number from config-maven action'
6-
required: false
73

8-
outputs:
9-
build-number:
10-
description: 'The build number used'
11-
value: ${{ steps.mvn-config.outputs.BUILD_NUMBER}}
12-
134
runs:
145
using: 'composite'
156
steps:
167
- name: Configure private maven projects
178
uses: SonarSource/ci-github-actions/[email protected]
18-
id: mvn-config
19-
env:
20-
BUILD_NUMBER: ${{ inputs.build-number }}
219

2210
- name: Update versions of public modules
2311
shell: bash
@@ -27,5 +15,3 @@ runs:
2715
# See BUILD-9394 for details
2816
cd private
2917
bash ${GITHUB_ACTION_PATH}/set_maven_version.sh
30-
env:
31-
BUILD_NUMBER: ${{ inputs.build-number || steps.mvn-config.outputs.BUILD_NUMBER }}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<sonar.pluginClass>org.sonar.plugins.python.PythonPlugin</sonar.pluginClass>
7777
<sonar.pluginName>Python</sonar.pluginName>
7878
<!-- Used as the build name when deployed to Artifactory -->
79-
<gitRepositoryName>sonar-python</gitRepositoryName>
79+
<gitRepositoryName>sonar-python-enterprise</gitRepositoryName>
8080
<!-- Release: enable publication to Bintray -->
8181
<artifactsToPublish>${project.groupId}:sonar-python-plugin:jar</artifactsToPublish>
8282
<!-- we depend on API ${sonar.version} but we keep backward compatibility with LTS -->

0 commit comments

Comments
 (0)