Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/jfrog/jfrog-client-go v1.28.1-0.20250629142537-bb24db402fe1

// 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 @@ -113,8 +113,8 @@ 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/jfrog/jfrog-client-go v1.28.1-0.20250629142537-bb24db402fe1 h1:0t6dQHoalUDNVrfZujD3iCmDGLDl+ndHclFkmONSpq0=
github.com/jfrog/jfrog-client-go v1.28.1-0.20250629142537-bb24db402fe1/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