Skip to content

Commit

Permalink
Add tracking query params to build info summary
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Jan 5, 2025
1 parent b26e9a6 commit ad2a78e
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 15 deletions.
4 changes: 4 additions & 0 deletions artifactory/utils/commandsummary/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func addGitHubTrackingToUrl(urlStr string, section summarySection) (string, erro

// Get the query parameters and add the GitHub tracking parameters
queryParams := parsedUrl.Query()
// Tracking source
queryParams.Set("s", "1")
// Tracking metric
queryParams.Set("m", "3")
queryParams.Set("gh_job_id", githubWorkflow)
queryParams.Set("gh_section", string(section))
parsedUrl.RawQuery = queryParams.Encode()
Expand Down
20 changes: 14 additions & 6 deletions artifactory/utils/commandsummary/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func TestGenerateArtifactUrl(t *testing.T) {
majorVersion int
expected string
}{
{"artifactory 7 without project", "", 7, "https://myplatform.com/ui/repos/tree/General/repo/path/file?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=test-section"},
{"artifactory 7 with project", "proj", 7, "https://myplatform.com/ui/repos/tree/General/repo/path/file?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=test-section"},
{"artifactory 6 without project", "", 6, "https://myplatform.com/artifactory/webapp/?gh_job_id=JFrog+CLI+Core+Tests&gh_section=test-section#/artifacts/browse/tree/General/repo/path/file"},
{"artifactory 7 without project", "", 7, "https://myplatform.com/ui/repos/tree/General/repo/path/file?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=test-section&m=3&s=1"},
{"artifactory 7 with project", "proj", 7, "https://myplatform.com/ui/repos/tree/General/repo/path/file?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=test-section&m=3&s=1"},
{"artifactory 6 without project", "", 6, "https://myplatform.com/artifactory/webapp/?gh_job_id=JFrog+CLI+Core+Tests&gh_section=test-section&m=3&s=1#/artifacts/browse/tree/General/repo/path/file"},
}
StaticMarkdownConfig.setPlatformUrl(testPlatformUrl)
for _, testCase := range cases {
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestAddGitHubTrackingToUrl(t *testing.T) {
"https://example.com/path",
buildInfoSection,
"workflow123",
"https://example.com/path?gh_job_id=workflow123&gh_section=buildInfo",
"https://example.com/path?gh_job_id=workflow123&gh_section=buildInfo&m=3&s=1",
false,
},
{
Expand All @@ -87,15 +87,23 @@ func TestAddGitHubTrackingToUrl(t *testing.T) {
"https://example.com/path?existing_param=value",
packagesSection,
"workflow123",
"https://example.com/path?existing_param=value&gh_job_id=workflow123&gh_section=packages",
"https://example.com/path?existing_param=value&gh_job_id=workflow123&gh_section=packages&m=3&s=1",
false,
},
{
"GITHUB_WORKFLOW with special characters",
"https://example.com/path",
artifactsSection,
"workflow with spaces & special?characters",
"https://example.com/path?gh_job_id=workflow+with+spaces+%26+special%3Fcharacters&gh_section=artifacts",
"https://example.com/path?gh_job_id=workflow+with+spaces+%26+special%3Fcharacters&gh_section=artifacts&m=3&s=1",
false,
},
{
"URL with spaces",
"https://example.com/path?existing_param=value",
packagesSection,
"workflow space",
"https://example.com/path?existing_param=value&gh_job_id=workflow+space&gh_section=packages&m=3&s=1",
false,
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


| Build Info| Security Violations| Security Issues|
|:---------|:------------|:------------|
| [buildName 123](http://myJFrogPlatform/builds/buildName/123?gh_job_id=JFrog+CLI+Core+Tests&gh_section=buildInfo) | Not scanned| Not scanned|
| Build Info | Security Violations | Security Issues |
| :--------- | :------------ | :------------ |
| [buildName 123](http://myJFrogPlatform/builds/buildName/123?gh_job_id=JFrog+CLI+Core+Tests&gh_section=buildInfo&m=3&s=1) | Not scanned | Not scanned |


Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

| Artifacts | Security Violations | Security Issues |
| :------------ | :--------------------- | :------------------ |
| <pre>πŸ“¦ docker-local<br>└── πŸ“ image2<br> └── πŸ“ sha256:552c<br> └── <a href='https://myplatform.com/ui/repos/tree/General/docker-local/image2/sha256:552c/sha256__aae9?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages' target="_blank">sha256__aae9</a><br><br></pre> | Not scanned | Not scanned |
| <pre>πŸ“¦ docker-local<br>└── πŸ“ image2<br> └── πŸ“ sha256:552c<br> └── <a href='https://myplatform.com/ui/repos/tree/General/docker-local/image2/sha256:552c/sha256__aae9?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages&m=3&s=1' target="_blank">sha256__aae9</a><br><br></pre> | Not scanned | Not scanned |
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<pre>πŸ“¦ generic-local
└── πŸ“ path
└── πŸ“ to
└── <a href='https://myplatform.com/ui/repos/tree/General/generic-local/path/to/artifact2?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=artifacts' target="_blank">artifact2</a>
└── <a href='https://myplatform.com/ui/repos/tree/General/generic-local/path/to/artifact2?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=artifacts&m=3&s=1' target="_blank">artifact2</a>

</pre>

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<pre>πŸ“¦ libs-release
└── πŸ“ path
└── πŸ“ to
└── <a href='https://myplatform.com/ui/repos/tree/General/libs-release/path/to/artifact1?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages' target="_blank">artifact1</a>
└── <a href='https://myplatform.com/ui/repos/tree/General/libs-release/path/to/artifact1?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages&m=3&s=1' target="_blank">artifact1</a>

</pre>

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
πŸ“¦ libs-release
└── πŸ“ path
└── πŸ“ to
└── <a href='https://myplatform.com/ui/repos/tree/General/libs-release/path/to/artifact2?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages' target="_blank">artifact2</a>
└── <a href='https://myplatform.com/ui/repos/tree/General/libs-release/path/to/artifact2?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages&m=3&s=1' target="_blank">artifact2</a>

</details></pre>

Expand All @@ -22,7 +22,7 @@
πŸ“¦ libs-release
└── πŸ“ path
└── πŸ“ to
└── <a href='https://myplatform.com/ui/repos/tree/General/libs-release/path/to/artifact3?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages' target="_blank">artifact3</a>
└── <a href='https://myplatform.com/ui/repos/tree/General/libs-release/path/to/artifact3?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages&m=3&s=1' target="_blank">artifact3</a>

</details></pre>

Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

| Artifacts | Security Violations | Security Issues |
| :------------ | :--------------------- | :------------------ |
| <pre><details><summary>linux/amd64/multiarch-image:1 <a href=https://myplatform.com/ui/packages/docker:%2F%2Fmultiarch-image/sha256__sha256:552c>(🐸 View)</a></summary><br>πŸ“¦ docker-local<br>└── πŸ“ multiarch-image<br> β”œβ”€β”€ πŸ“ sha256:552c<br> β”‚ └── <a href='https://myplatform.com/ui/repos/tree/General/docker-local/multiarch-image/sha256:552c/sha256?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages' target="_blank">sha256</a><br> └── <a href='https://myplatform.com/ui/repos/tree/General/docker-local/multiarch-image/sha256?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages' target="_blank">sha256</a><br><br></details></pre> | Not scanned | Not scanned |
| <pre><details><summary>linux/amd64/multiarch-image:1 <a href=https://myplatform.com/ui/packages/docker:%2F%2Fmultiarch-image/sha256__sha256:552c>(🐸 View)</a></summary><br>πŸ“¦ docker-local<br>└── πŸ“ multiarch-image<br> β”œβ”€β”€ πŸ“ sha256:552c<br> β”‚ └── <a href='https://myplatform.com/ui/repos/tree/General/docker-local/multiarch-image/sha256:552c/sha256?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages&m=3&s=1' target="_blank">sha256</a><br> └── <a href='https://myplatform.com/ui/repos/tree/General/docker-local/multiarch-image/sha256?clearFilter=true&gh_job_id=JFrog+CLI+Core+Tests&gh_section=packages&m=3&s=1' target="_blank">sha256</a><br><br></details></pre> | Not scanned | Not scanned |

0 comments on commit ad2a78e

Please sign in to comment.