Skip to content

Commit 6371b6e

Browse files
committed
Migrate the plugin source to consume Jfrog SDK instead of Jfrog CLI
1 parent 8d801fc commit 6371b6e

28 files changed

+2451
-306
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A plugin to upload files to Jfrog artifactory.
1+
A plugin to upload files to Jfrog Artifactory. Now implemented using the JFrog Go Client SDK (no JFrog CLI dependency at runtime).
22

33
Run the following script to install git-leaks support to this repo.
44
```
@@ -56,12 +56,19 @@ docker run --rm \
5656
build_number: <+pipeline.executionId>
5757
target_props: key1=value1,key2=value2
5858
```
59+
Notes:
60+
- JFrog CLI is no longer required; the plugin uses `github.com/jfrog/jfrog-client-go` and `github.com/jfrog/build-info-go` under the hood.
61+
- Custom CA certificates can still be provided via `PLUGIN_PEM_FILE_CONTENTS` / `PLUGIN_PEM_FILE_PATH`; insecure TLS can be enabled via `PLUGIN_INSECURE=true`.
62+
5963
### Maven Build and Publish reference
6064
[Go to Maven reference](./docs/MAVEN_README.md)
6165

6266
### Gradle Build and Publish reference
6367
[Go to Gradle reference](./docs/GRADLE_README.md)
6468

69+
### Multi-Step Build-Info Flow
70+
[End-to-end example: Upload → Add Deps → Download → Publish → Cleanup](./docs/BUILD_INFO_FLOW.md)
71+
6572
## Community and Support
6673
[Harness Community Slack](https://join.slack.com/t/harnesscommunity/shared_invite/zt-y4hdqh7p-RVuEQyIl5Hcx4Ck8VCvzBw) - Join the #drone slack channel to connect with our engineers and other users running Drone CI.
6774

docker/Dockerfile.linux.amd64

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ RUN curl -fsSL https://services.gradle.org/distributions/gradle-${GRADLE_VERSION
2828
&& rm /tmp/gradle.zip \
2929
&& ln -s /opt/gradle/gradle-${GRADLE_VERSION}/bin/gradle /usr/local/bin/gradle
3030

31-
# Install JFrog CLI
32-
RUN curl -fL https://getcli.jfrog.io/v2-jf | sh /dev/stdin 2.73.2
33-
RUN mv ./jf /usr/local/bin/jf
34-
RUN chmod +x /usr/local/bin/jf
35-
3631
# Add your custom plugin
3732
ADD release/linux/amd64/plugin /bin/
3833

docker/Dockerfile.linux.arm64

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,5 @@ RUN curl -fsSL https://services.gradle.org/distributions/gradle-${GRADLE_VERSION
2828
&& rm /tmp/gradle.zip \
2929
&& ln -s /opt/gradle/gradle-${GRADLE_VERSION}/bin/gradle /usr/local/bin/gradle
3030

31-
# Install JFrog CLI
32-
RUN curl -fL https://getcli.jfrog.io/v2-jf | sh /dev/stdin 2.73.2
33-
RUN mv ./jf /usr/local/bin/jf
34-
RUN chmod +x /usr/local/bin/jf
35-
3631
ADD release/linux/arm64/plugin /bin/
3732
ENTRYPOINT ["/bin/plugin"]

docker/Dockerfile.windows.amd64.1809

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ COPY docker/cert.windows.pem docker/cacert.pem C:\users\ContainerAdministrator\.
2323
# Generate CA certificates and download/install tools in a single layer
2424
RUN certutil -generateSSTFromWU C:\certificates\ca-certificates.sst; `
2525
`
26-
# Download JFrog CLI
27-
Invoke-WebRequest -Uri https://releases.jfrog.io/artifactory/jfrog-cli/v2/2.68.0/jfrog-cli-windows-amd64/jfrog.exe -OutFile C:\bin\jfrog.exe; `
28-
`
26+
2927
# Download and install JDK
3028
Invoke-WebRequest -Uri "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8%2B7/OpenJDK17U-jdk_x64_windows_hotspot_17.0.8_7.zip" -OutFile "C:\jdk.zip"; `
3129
Expand-Archive -Path "C:\jdk.zip" -DestinationPath "C:\jdk"; `
@@ -48,7 +46,7 @@ RUN mkdir C:\bin C:\certificates C:\temp C:\uploads C:\jdk C:\maven C:\gradle
4846
# Copy certificates, JFrog CLI, JDK, Maven, and Gradle from builder stage
4947
COPY --from=builder C:\certificates C:\certificates
5048
COPY --from=builder C:\users\ContainerAdministrator\.jfrog C:\users\ContainerAdministrator\.jfrog
51-
COPY --from=builder C:\bin\jfrog.exe C:\bin\jfrog.exe
49+
5250
COPY --from=builder C:\jdk C:\jdk
5351
COPY --from=builder C:\maven C:\maven
5452
COPY --from=builder C:\gradle C:\gradle

docker/Dockerfile.windows.amd64.ltsc2022

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ COPY docker/cert.windows.pem docker/cacert.pem C:\users\ContainerAdministrator\.
2323
# Generate CA certificates and download/install tools in a single layer
2424
RUN certutil -generateSSTFromWU C:\certificates\ca-certificates.sst; `
2525
`
26-
# Download JFrog CLI
27-
Invoke-WebRequest -Uri https://releases.jfrog.io/artifactory/jfrog-cli/v2/2.68.0/jfrog-cli-windows-amd64/jfrog.exe -OutFile C:\bin\jfrog.exe; `
28-
`
26+
2927
# Download and install JDK
3028
Invoke-WebRequest -Uri "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.8%2B7/OpenJDK17U-jdk_x64_windows_hotspot_17.0.8_7.zip" -OutFile "C:\jdk.zip"; `
3129
Expand-Archive -Path "C:\jdk.zip" -DestinationPath "C:\jdk"; `
@@ -48,7 +46,7 @@ RUN mkdir C:\bin C:\certificates C:\temp C:\uploads C:\jdk C:\maven C:\gradle
4846
# Copy certificates, JFrog CLI, JDK, Maven, and Gradle from builder stage
4947
COPY --from=builder C:\certificates C:\certificates
5048
COPY --from=builder C:\users\ContainerAdministrator\.jfrog C:\users\ContainerAdministrator\.jfrog
51-
COPY --from=builder C:\bin\jfrog.exe C:\bin\jfrog.exe
49+
5250
COPY --from=builder C:\jdk C:\jdk
5351
COPY --from=builder C:\maven C:\maven
5452
COPY --from=builder C:\gradle C:\gradle
@@ -65,4 +63,4 @@ ENV CI="true"
6563
# Add plugin executable
6664
COPY release/windows/amd64/plugin C:/bin/drone-artifactory.exe
6765

68-
ENTRYPOINT [ "C:\\bin\\drone-artifactory.exe" ]
66+
ENTRYPOINT [ "C:\\bin\\drone-artifactory.exe" ]

docs/ADD_BUILD_DEPENDENCIES_README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A plugin to upload files to Jfrog artifactory.
1+
A plugin to upload files to JFrog Artifactory.
22

33
Run the following script to install git-leaks support to this repo.
44
```
@@ -23,6 +23,10 @@ docker build -t plugins/artifactory -f docker/Dockerfile .
2323
# Adds dependencies from the local file-system to the build info
2424
This step is used to add dependencies from the local file-system to the build info.
2525
The dependencies are added to the build info in the Artifactory server.
26+
Notes:
27+
- No JFrog CLI required. The plugin uses the JFrog Go Client SDK.
28+
- Dependencies are saved locally as build-info partials. Use `publish-build-info` or set `publish_build_info: true` to publish aggregated build-info.
29+
- To collect from Artifactory instead of filesystem, set `from_rt: true` and provide a `dependency` pattern or a `spec_path`.
2630

2731
### Add dependencies with a dependency pattern:
2832
```yaml

docs/BUILD_INFO_FLOW.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
Multi-Step Build Info Pipeline (Upload → Add Deps → Download → Publish → Cleanup)
2+
3+
Overview
4+
- No JFrog CLI required; the plugin uses the JFrog Go Client SDK.
5+
- Upload, Download, and Add-Build-Dependencies steps save build-info partials locally using build-info-go.
6+
- Publish step aggregates and publishes the full build-info to Artifactory.
7+
- Optional auto-clean and explicit cleanup supported.
8+
9+
Example (Harness CI Plugin steps)
10+
11+
```yaml
12+
# 1) Upload artifacts and accumulate build-info (partials)
13+
- step:
14+
type: Plugin
15+
name: UploadArtifacts
16+
identifier: UploadArtifacts
17+
spec:
18+
connectorRef: account.harnessImage
19+
image: plugins/artifactory:linux-amd64
20+
settings:
21+
url: https://URL.jfrog.io/artifactory
22+
username: user
23+
password: <+secrets.getValue("jfrog_password")>
24+
# Either use source/target or a file spec
25+
source: /harness/build/output/**/*.jar
26+
target: libs-release-local/path/in/repo/
27+
build_name: sample-build
28+
build_number: 123
29+
# Optional: properties on target
30+
target_props: key1=value1,key2=value2
31+
# Do not publish yet (accumulate partials)
32+
publish_build_info: false
33+
34+
# 2) Add build dependencies (from filesystem). Also accumulates partials
35+
- step:
36+
type: Plugin
37+
name: AddBuildDependencies
38+
identifier: AddBuildDependencies
39+
spec:
40+
connectorRef: account.harnessImage
41+
image: plugins/artifactory:linux-amd64
42+
settings:
43+
command: add-build-dependencies
44+
url: https://URL.jfrog.io
45+
username: user
46+
password: <+secrets.getValue("jfrog_password")>
47+
build_name: sample-build
48+
build_number: 123
49+
module: generic-module
50+
# Collect dependencies from local filesystem
51+
dependency: /harness/inputs/**/*.zip
52+
# Or collect from Artifactory:
53+
# from_rt: true
54+
# dependency: libs-release-local/**/*.jar
55+
56+
# 3) Download artifacts (records dependencies into build-info partials)
57+
- step:
58+
type: Plugin
59+
name: DownloadArtifacts
60+
identifier: DownloadArtifacts
61+
spec:
62+
connectorRef: account.harnessImage
63+
image: plugins/artifactory:linux-amd64
64+
settings:
65+
command: download
66+
url: https://URL.jfrog.io/artifactory
67+
username: user
68+
password: <+secrets.getValue("jfrog_password")>
69+
build_name: sample-build
70+
build_number: 123
71+
module: generic-module
72+
# Use a file spec (recommended)
73+
spec: |
74+
{
75+
"files": [
76+
{ "pattern": "libs-release-local/com/example/**/artifact-*.jar",
77+
"target": "./downloads/",
78+
"recursive": "true",
79+
"flat": "false"
80+
}
81+
]
82+
}
83+
84+
# 4) Publish build-info (aggregates all partials). Optionally auto-clean afterwards
85+
- step:
86+
type: Plugin
87+
name: PublishBuildInfo
88+
identifier: PublishBuildInfo
89+
spec:
90+
connectorRef: account.harnessImage
91+
image: plugins/artifactory:linux-amd64
92+
settings:
93+
command: publish-build-info
94+
url: https://URL.jfrog.io
95+
username: user
96+
password: <+secrets.getValue("jfrog_password")>
97+
build_name: sample-build
98+
build_number: 123
99+
cleanup_after_publish: true
100+
101+
# 5) (Optional) Explicit cleanup step (only needed if not using cleanup_after_publish)
102+
- step:
103+
type: Plugin
104+
name: CleanBuildInfo
105+
identifier: CleanBuildInfo
106+
spec:
107+
connectorRef: account.harnessImage
108+
image: plugins/artifactory:linux-amd64
109+
settings:
110+
command: cleanup
111+
build_name: sample-build
112+
build_number: 123
113+
```
114+
115+
Notes
116+
- TLS: Provide custom CA PEM via `pem_file_contents` or `pem_file_path`. To skip verification, set `insecure: true`.
117+
- Access token: You can use `access_token` in place of `username`/`password`.
118+
- If you prefer to publish after each operation, set `publish_build_info: true` on those steps (and optionally `cleanup_after_publish: true`).
119+

docs/DOWNLOAD_README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A plugin to download files from Jfrog artifactory.
1+
A plugin to download files from JFrog Artifactory.
22

33
Run the following script to install git-leaks support to this repo.
44
```
@@ -20,10 +20,14 @@ Build the plugin image:
2020
docker build -t plugins/artifactory -f docker/Dockerfile .
2121
```
2222

23-
# Download artifact to Jfrog Artifactory
23+
# Download artifact to JFrog Artifactory
2424
This step downloads the artifacts from Jfrog Artifactory.
2525
A valid spec or a spec path given as an argument is mandatory.
2626
The spec json format should be the same as Jfrog spec format
27+
Notes:
28+
- No JFrog CLI required. The plugin uses the JFrog Go Client SDK.
29+
- Build-info dependencies from downloads are saved locally and can be published later using `publish-build-info` or by setting `publish_build_info: true` in this step.
30+
- TLS: Provide custom CA PEM via `pem_file_contents`/`pem_file_path`, or set `insecure: true` to skip verification.
2731

2832
### Download artifact to Jfrog Artifactory using spec path example:
2933
```yaml

docs/GRADLE_README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A plugin to upload files to Jfrog artifactory.
1+
A plugin to upload files to Jfrog Artifactory.
22

33
Run the following script to install git-leaks support to this repo.
44
```
@@ -24,6 +24,10 @@ docker build -t plugins/artifactory -f docker/Dockerfile .
2424
- Gradle build step is used to build the Gradle project and create artifacts.
2525
- Publish step is used to publish the Gradle project artifacts to the artifactory repositories.
2626
- Authentication for Jfrog artifactory can be done using Username and Password or Access Token. Refer to below examples.
27+
- This plugin no longer requires JFrog CLI. It uses the JFrog Go Client SDK. For Gradle, the plugin generates a temporary `init.gradle` that injects resolver and (if applicable) publishing repositories and credentials, then invokes `gradle` natively.
28+
- Build-info is accumulated locally and can be published using `publish-build-info` command or `publish_build_info: true`.
29+
- Module IDs: When `build_tool: gradle` and no `module` is provided, the plugin derives the module ID from Gradle project properties (`group:name:version`) similar to JFrog CLI extractors. If Gradle is not available or values are missing, the module defaults to `generic`. To override, set the `module` input.
30+
- TLS: Provide custom CA PEM contents via `pem_file_contents` or a path via `pem_file_path`. To skip TLS verification, set `insecure: true`.
2731
- Additional build discard with below parameters can be done.
2832
- delete_artifacts: The flag to delete the artifacts, if not set will only delete build metadata.
2933
- exclude_builds: The builds to exclude from deletion.
@@ -87,6 +91,10 @@ The config is same as the "Gradle Publish step example using Username and Passwo
8791
"password" should be set as the access token value, access token will be a very long string
8892
8993
94+
## Notes on Build-Info Behavior
95+
- Upload, download, and add-build-dependencies save build-info partials locally. Use `publish-build-info` to aggregate and publish, or set `publish_build_info: true` to publish in the same step.
96+
- Use `command: cleanup` with `build_name` and `build_number` to remove local cached build-info for that build.
97+
9098
### Gradle Publish step with build discard additional parameters
9199
```yaml
92100
- step:

docs/MAVEN_README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A plugin to upload files to Jfrog artifactory.
1+
A plugin to upload files to Jfrog Artifactory.
22

33
Run the following script to install git-leaks support to this repo.
44
```
@@ -21,9 +21,14 @@ docker build -t plugins/artifactory -f docker/Dockerfile .
2121
```
2222

2323
# Maven Build and Publish
24+
- This plugin no longer requires JFrog CLI. It uses the JFrog Go Client SDK under the hood.
25+
- For Maven, the plugin generates a temporary `settings.xml` with resolver and deploy repositories and credentials based on the provided inputs, and then invokes `mvn` natively.
26+
- Build-info is accumulated locally across steps and can be published using the `publish-build-info` command or by setting `publish_build_info: true`.
27+
- Module IDs: When `build_tool: mvn` and no `module` is provided, the plugin derives the module ID from the POM as `groupId:artifactId:version` (similar to JFrog CLI extractors). To override, set the `module` input.
2428
- Maven build step is used to build the maven project and create artifacts.
2529
- Publish step is used to publish the maven project artifacts to the artifactory repositories.
2630
- Authentication for Jfrog artifactory can be done using Username and Password or Access Token. Refer to below examples.
31+
- TLS: Provide custom CA PEM contents via `pem_file_contents` or a path via `pem_file_path`. To skip TLS verification, set `insecure: true`.
2732
- Additional build discard with below parameters can be done.
2833
- delete_artifacts: The flag to delete the artifacts, if not set will only delete build metadata.
2934
- exclude_builds: The builds to exclude from deletion.
@@ -126,6 +131,11 @@ docker build -t plugins/artifactory -f docker/Dockerfile .
126131
127132
128133
134+
## Notes on Build-Info Behavior
135+
- Upload, download, and add-build-dependencies commands save build-info partials locally. Use `publish-build-info` to aggregate and publish, or set `publish_build_info: true` in the step to publish after the operation.
136+
- Use `command: cleanup` with `build_name` and `build_number` to remove local cached build-info for that build.
137+
138+
129139
## Community and Support
130140
[Harness Community Slack](https://join.slack.com/t/harnesscommunity/shared_invite/zt-y4hdqh7p-RVuEQyIl5Hcx4Ck8VCvzBw) - Join the #drone slack channel to connect with our engineers and other users running Drone CI.
131141

0 commit comments

Comments
 (0)