Skip to content
Snippets Groups Projects
Commit 148b9011 authored by Pavel Pletenev's avatar Pavel Pletenev Committed by Christoph Witzko
Browse files

feat: Align algorith to aquire tokens with goreleaser

parent 6f581f8b
Branches
Tags
No related merge requests found
...@@ -38,19 +38,19 @@ func (repo *GitLabRepository) Init(config map[string]string) error { ...@@ -38,19 +38,19 @@ func (repo *GitLabRepository) Init(config map[string]string) error {
token := config["token"] token := config["token"]
if token == "" { if token == "" {
token = os.Getenv("GITLAB_TOKEN") token = os.Getenv("GITLAB_TOKEN")
} ci_job_token := os.Getenv("CI_JOB_TOKEN")
if token == "" {
token = os.Getenv("CI_JOB_TOKEN")
repo.useJobToken = true
if token == "" { if token == "" {
if ci_job_token == "" {
return errors.New("gitlab token missing") return errors.New("gitlab token missing")
} }
token = ci_job_token
}
// use the same strategy as goreleaser
if token == ci_job_token {
repo.useJobToken = true
if os.Getenv("GIT_STRATEGY") == "none" { if os.Getenv("GIT_STRATEGY") == "none" {
return errors.New("can not use job token with sparse-checkout repository") return errors.New("can not use job token with sparse-checkout repository")
} }
repo.localRepo = &GitProvider.Repository{} repo.localRepo = &GitProvider.Repository{}
err := repo.localRepo.Init(map[string]string{ err := repo.localRepo.Init(map[string]string{
"remote_name": "origin", "remote_name": "origin",
...@@ -61,6 +61,7 @@ func (repo *GitLabRepository) Init(config map[string]string) error { ...@@ -61,6 +61,7 @@ func (repo *GitLabRepository) Init(config map[string]string) error {
return errors.New("failed to initialize local git repository: " + err.Error()) return errors.New("failed to initialize local git repository: " + err.Error())
} }
} }
}
branch := config["gitlab_branch"] branch := config["gitlab_branch"]
if branch == "" { if branch == "" {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment