Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion common/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,10 @@ func exchangeOidcTokenAndSetAccessToken(cc *ConfigCommand) error {
SetProjectKey(cc.oidcSetupParams.ProjectKey).
SetRepository(cc.oidcSetupParams.Repository).
SetJobId(cc.oidcSetupParams.JobId).
SetRunId(cc.oidcSetupParams.RunId)
SetRunId(cc.oidcSetupParams.RunId).
SetVcsRevision(cc.oidcSetupParams.VcsRevision).
SetVcsBranch(cc.oidcSetupParams.VcsBranch).
SetVcsUrl(cc.oidcSetupParams.VcsUrl)

// Usage report will be sent only after execution in order to have valid token
err := ExecAndThenReportUsage(exchangeOidcTokenCmd)
Expand Down
32 changes: 30 additions & 2 deletions general/token/oidctokenexchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package token
import (
"encoding/json"
"fmt"
"os"
"strings"

rtUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-client-go/access/services"
"github.com/jfrog/jfrog-client-go/auth"
"github.com/jfrog/jfrog-client-go/utils/log"
"os"
"strings"
)

const (
Expand Down Expand Up @@ -73,6 +74,9 @@ type OidcParams struct {
JobId string
RunId string
Repository string
VcsUrl string
VcsBranch string
VcsRevision string
}

type ExchangeCommandOutputStruct struct {
Expand Down Expand Up @@ -133,6 +137,21 @@ func (otc *OidcTokenExchangeCommand) SetRepository(repo string) *OidcTokenExchan
return otc
}

func (otc *OidcTokenExchangeCommand) SetVcsUrl(vcsUrl string) *OidcTokenExchangeCommand {
otc.VcsUrl = vcsUrl
return otc
}

func (otc *OidcTokenExchangeCommand) SetVcsBranch(vcsBranch string) *OidcTokenExchangeCommand {
otc.VcsBranch = vcsBranch
return otc
}

func (otc *OidcTokenExchangeCommand) SetVcsRevision(vcsRevision string) *OidcTokenExchangeCommand {
otc.VcsRevision = vcsRevision
return otc
}

func (otc *OidcTokenExchangeCommand) Response() (response *auth.OidcTokenResponseData) {
return otc.response
}
Expand Down Expand Up @@ -191,5 +210,14 @@ func (otc *OidcTokenExchangeCommand) getOidcTokenParams() services.CreateOidcTok
oidcTokenParams.Repo = otc.Repository
oidcTokenParams.Audience = otc.Audience
oidcTokenParams.ProviderName = otc.ProviderName
oidcTokenParams.ProviderType = otc.ProviderType.String()
oidcTokenParams.Context = &services.Context{
VcsCommit: &services.VcsCommit{
VcsUrl: otc.VcsUrl,
Branch: otc.VcsBranch,
Revision: otc.VcsRevision,
},
}

return oidcTokenParams
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ require (
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d
replace github.com/jfrog/jfrog-client-go => github.com/eyaldelarea/jfrog-client-go v1.28.1-0.20250626103452-b91dcacefe3e

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20250611113558-c1a092f216fd

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o
github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/eyaldelarea/jfrog-client-go v1.28.1-0.20250626103452-b91dcacefe3e h1:0TizssmoBAbo1mH26/yrGVHAVgpzKMvIZn9+Qu2b200=
github.com/eyaldelarea/jfrog-client-go v1.28.1-0.20250626103452-b91dcacefe3e/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY=
github.com/forPelevin/gomoji v1.3.0 h1:WPIOLWB1bvRYlKZnSSEevLt3IfKlLs+tK+YA9fFYlkE=
github.com/forPelevin/gomoji v1.3.0/go.mod h1:mM6GtmCgpoQP2usDArc6GjbXrti5+FffolyQfGgPboQ=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
Expand Down Expand Up @@ -113,8 +115,6 @@ github.com/jfrog/build-info-go v1.10.14 h1:PWnw+rBwiQTHZ5q+84+E8MHFjtAQkB3+Oc2sK
github.com/jfrog/build-info-go v1.10.14/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE=
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d h1:0TNgRnYr92lmxC4my2P07MqaWmYBuLP/sgoCD5k/fhA=
github.com/jfrog/jfrog-client-go v1.28.1-0.20250619121353-6ff3439c999d/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down
7 changes: 5 additions & 2 deletions utils/coreutils/coreconsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ var (
//#nosec G101
EncryptionKey = "JFROG_CLI_ENCRYPTION_KEY"
// For CI runs
CIJobID = "JFROG_CLI_CI_JOB_ID"
CIRunID = "JFROG_CLI_CI_RUN_ID"
CIJobID = "JFROG_CLI_CI_JOB_ID"
CIRunID = "JFROG_CLI_CI_RUN_ID"
CIVcsUrl = "JFROG_CLI_CI_VCS_URL"
CIVcsRevision = "JFROG_CLI_CI_VCS_REVISION"
CIVcsBranch = "JFROG_CLI_CI_BRANCH"
)
Loading