mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-02 21:58:43 +00:00
Add SSH clone URL env var (#2198)
to improve https://github.com/woodpecker-ci/plugin-git/pull/75
This commit is contained in:
parent
f5e9b3df2e
commit
4d83ea0de8
13 changed files with 69 additions and 29 deletions
|
@ -150,6 +150,10 @@ var flags = []cli.Flag{
|
||||||
EnvVars: []string{"CI_REPO_CLONE_URL"},
|
EnvVars: []string{"CI_REPO_CLONE_URL"},
|
||||||
Name: "repo-clone-url",
|
Name: "repo-clone-url",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
EnvVars: []string{"CI_REPO_CLONE_SSH_URL"},
|
||||||
|
Name: "repo-clone-ssh-url",
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_REPO_PRIVATE"},
|
EnvVars: []string{"CI_REPO_PRIVATE"},
|
||||||
Name: "repo-private",
|
Name: "repo-private",
|
||||||
|
|
|
@ -42,13 +42,14 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata {
|
||||||
|
|
||||||
return metadata.Metadata{
|
return metadata.Metadata{
|
||||||
Repo: metadata.Repo{
|
Repo: metadata.Repo{
|
||||||
Name: repoName,
|
Name: repoName,
|
||||||
Owner: repoOwner,
|
Owner: repoOwner,
|
||||||
RemoteID: c.String("repo-remote-id"),
|
RemoteID: c.String("repo-remote-id"),
|
||||||
Link: c.String("repo-link"),
|
Link: c.String("repo-link"),
|
||||||
CloneURL: c.String("repo-clone-url"),
|
CloneURL: c.String("repo-clone-url"),
|
||||||
Private: c.Bool("repo-private"),
|
CloneSSHURL: c.String("repo-clone-ssh-url"),
|
||||||
Trusted: c.Bool("repo-trusted"),
|
Private: c.Bool("repo-private"),
|
||||||
|
Trusted: c.Bool("repo-trusted"),
|
||||||
},
|
},
|
||||||
Curr: metadata.Pipeline{
|
Curr: metadata.Pipeline{
|
||||||
Number: c.Int64("pipeline-number"),
|
Number: c.Int64("pipeline-number"),
|
||||||
|
|
|
@ -3908,6 +3908,9 @@ const docTemplate = `{
|
||||||
"clone_url": {
|
"clone_url": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"clone_url_ssh": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"config_file": {
|
"config_file": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -57,7 +57,8 @@ This is the reference list of all environment variables available to your pipeli
|
||||||
| `CI_REPO_SCM` | repository SCM (git) |
|
| `CI_REPO_SCM` | repository SCM (git) |
|
||||||
| `CI_REPO_URL` | repository web URL |
|
| `CI_REPO_URL` | repository web URL |
|
||||||
| `CI_REPO_CLONE_URL` | repository clone URL |
|
| `CI_REPO_CLONE_URL` | repository clone URL |
|
||||||
| `CI_REPO_DEFAULT_BRANCH` | repository default branch (main) |
|
| `CI_REPO_CLONE_SSH_URL` | repository SSH clone URL |
|
||||||
|
| `CI_REPO_DEFAULT_BRANCH` | repository default branch (main) |
|
||||||
| `CI_REPO_PRIVATE` | repository is private |
|
| `CI_REPO_PRIVATE` | repository is private |
|
||||||
| `CI_REPO_TRUSTED` | repository is trusted |
|
| `CI_REPO_TRUSTED` | repository is trusted |
|
||||||
| | **Current Commit** |
|
| | **Current Commit** |
|
||||||
|
|
|
@ -55,14 +55,15 @@ func MetadataFromStruct(forge metadata.ServerForge, repo *model.Repo, pipeline,
|
||||||
fRepo := metadata.Repo{}
|
fRepo := metadata.Repo{}
|
||||||
if repo != nil {
|
if repo != nil {
|
||||||
fRepo = metadata.Repo{
|
fRepo = metadata.Repo{
|
||||||
Name: repo.Name,
|
Name: repo.Name,
|
||||||
Owner: repo.Owner,
|
Owner: repo.Owner,
|
||||||
RemoteID: fmt.Sprint(repo.ForgeRemoteID),
|
RemoteID: fmt.Sprint(repo.ForgeRemoteID),
|
||||||
Link: repo.Link,
|
Link: repo.Link,
|
||||||
CloneURL: repo.Clone,
|
CloneURL: repo.Clone,
|
||||||
Private: repo.IsSCMPrivate,
|
CloneSSHURL: repo.CloneSSH,
|
||||||
Branch: repo.Branch,
|
Private: repo.IsSCMPrivate,
|
||||||
Trusted: repo.IsTrusted,
|
Branch: repo.Branch,
|
||||||
|
Trusted: repo.IsTrusted,
|
||||||
}
|
}
|
||||||
|
|
||||||
if idx := strings.LastIndex(repo.FullName, "/"); idx != -1 {
|
if idx := strings.LastIndex(repo.FullName, "/"); idx != -1 {
|
||||||
|
|
|
@ -45,6 +45,7 @@ func (m *Metadata) Environ() map[string]string {
|
||||||
"CI_REPO_SCM": "git",
|
"CI_REPO_SCM": "git",
|
||||||
"CI_REPO_URL": m.Repo.Link,
|
"CI_REPO_URL": m.Repo.Link,
|
||||||
"CI_REPO_CLONE_URL": m.Repo.CloneURL,
|
"CI_REPO_CLONE_URL": m.Repo.CloneURL,
|
||||||
|
"CI_REPO_CLONE_SSH_URL": m.Repo.CloneSSHURL,
|
||||||
"CI_REPO_DEFAULT_BRANCH": m.Repo.Branch,
|
"CI_REPO_DEFAULT_BRANCH": m.Repo.Branch,
|
||||||
"CI_REPO_PRIVATE": strconv.FormatBool(m.Repo.Private),
|
"CI_REPO_PRIVATE": strconv.FormatBool(m.Repo.Private),
|
||||||
"CI_REPO_TRUSTED": strconv.FormatBool(m.Repo.Trusted),
|
"CI_REPO_TRUSTED": strconv.FormatBool(m.Repo.Trusted),
|
||||||
|
|
|
@ -29,15 +29,16 @@ type (
|
||||||
|
|
||||||
// Repo defines runtime metadata for a repository.
|
// Repo defines runtime metadata for a repository.
|
||||||
Repo struct {
|
Repo struct {
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Owner string `json:"owner,omitempty"`
|
Owner string `json:"owner,omitempty"`
|
||||||
RemoteID string `json:"remote_id,omitempty"`
|
RemoteID string `json:"remote_id,omitempty"`
|
||||||
Link string `json:"link,omitempty"`
|
Link string `json:"link,omitempty"`
|
||||||
CloneURL string `json:"clone_url,omitempty"`
|
CloneURL string `json:"clone_url,omitempty"`
|
||||||
Private bool `json:"private,omitempty"`
|
CloneSSHURL string `json:"clone_url_ssh,omitempty"`
|
||||||
Secrets []Secret `json:"secrets,omitempty"`
|
Private bool `json:"private,omitempty"`
|
||||||
Branch string `json:"default_branch,omitempty"`
|
Secrets []Secret `json:"secrets,omitempty"`
|
||||||
Trusted bool `json:"trusted,omitempty"`
|
Branch string `json:"default_branch,omitempty"`
|
||||||
|
Trusted bool `json:"trusted,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pipeline defines runtime metadata for a pipeline.
|
// Pipeline defines runtime metadata for a pipeline.
|
||||||
|
|
|
@ -79,7 +79,7 @@ func TestMetadataFromStruct(t *testing.T) {
|
||||||
"CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "",
|
"CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "",
|
||||||
"CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0",
|
"CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0",
|
||||||
"CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "0", "CI_PREV_PIPELINE_PARENT": "0",
|
"CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "0", "CI_PREV_PIPELINE_PARENT": "0",
|
||||||
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "", "CI_REPO": "", "CI_REPO_CLONE_URL": "", "CI_REPO_DEFAULT_BRANCH": "", "CI_REPO_REMOTE_ID": "",
|
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "", "CI_REPO": "", "CI_REPO_CLONE_URL": "", "CI_REPO_CLONE_SSH_URL": "", "CI_REPO_DEFAULT_BRANCH": "", "CI_REPO_REMOTE_ID": "",
|
||||||
"CI_REPO_NAME": "", "CI_REPO_OWNER": "", "CI_REPO_PRIVATE": "false", "CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_URL": "", "CI_STEP_FINISHED": "",
|
"CI_REPO_NAME": "", "CI_REPO_OWNER": "", "CI_REPO_PRIVATE": "false", "CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_URL": "", "CI_STEP_FINISHED": "",
|
||||||
"CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_STATUS": "", "CI_SYSTEM_HOST": "", "CI_SYSTEM_NAME": "woodpecker",
|
"CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_STATUS": "", "CI_SYSTEM_HOST": "", "CI_SYSTEM_NAME": "woodpecker",
|
||||||
"CI_SYSTEM_PLATFORM": "", "CI_SYSTEM_URL": "", "CI_SYSTEM_VERSION": "", "CI_WORKFLOW_NAME": "", "CI_WORKFLOW_NUMBER": "0",
|
"CI_SYSTEM_PLATFORM": "", "CI_SYSTEM_URL": "", "CI_SYSTEM_VERSION": "", "CI_WORKFLOW_NAME": "", "CI_WORKFLOW_NUMBER": "0",
|
||||||
|
@ -88,7 +88,7 @@ func TestMetadataFromStruct(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "Test with forge",
|
name: "Test with forge",
|
||||||
forge: forge,
|
forge: forge,
|
||||||
repo: &model.Repo{FullName: "testUser/testRepo", Link: "https://gitea.com/testUser/testRepo", Clone: "https://gitea.com/testUser/testRepo.git", Branch: "main", IsSCMPrivate: true},
|
repo: &model.Repo{FullName: "testUser/testRepo", Link: "https://gitea.com/testUser/testRepo", Clone: "https://gitea.com/testUser/testRepo.git", CloneSSH: "git@gitea.com:testUser/testRepo.git", Branch: "main", IsSCMPrivate: true},
|
||||||
pipeline: &model.Pipeline{Number: 3},
|
pipeline: &model.Pipeline{Number: 3},
|
||||||
last: &model.Pipeline{Number: 2},
|
last: &model.Pipeline{Number: 2},
|
||||||
workflow: &model.Workflow{Name: "hello"},
|
workflow: &model.Workflow{Name: "hello"},
|
||||||
|
@ -96,7 +96,7 @@ func TestMetadataFromStruct(t *testing.T) {
|
||||||
expectedMetadata: metadata.Metadata{
|
expectedMetadata: metadata.Metadata{
|
||||||
Forge: metadata.Forge{Type: "gitea", URL: "https://gitea.com"},
|
Forge: metadata.Forge{Type: "gitea", URL: "https://gitea.com"},
|
||||||
Sys: metadata.System{Name: "woodpecker", Host: "example.com", Link: "https://example.com"},
|
Sys: metadata.System{Name: "woodpecker", Host: "example.com", Link: "https://example.com"},
|
||||||
Repo: metadata.Repo{Owner: "testUser", Name: "testRepo", Link: "https://gitea.com/testUser/testRepo", CloneURL: "https://gitea.com/testUser/testRepo.git", Branch: "main", Private: true},
|
Repo: metadata.Repo{Owner: "testUser", Name: "testRepo", Link: "https://gitea.com/testUser/testRepo", CloneURL: "https://gitea.com/testUser/testRepo.git", CloneSSHURL: "git@gitea.com:testUser/testRepo.git", Branch: "main", Private: true},
|
||||||
Curr: metadata.Pipeline{Number: 3},
|
Curr: metadata.Pipeline{Number: 3},
|
||||||
Prev: metadata.Pipeline{Number: 2},
|
Prev: metadata.Pipeline{Number: 2},
|
||||||
Workflow: metadata.Workflow{Name: "hello"},
|
Workflow: metadata.Workflow{Name: "hello"},
|
||||||
|
@ -111,7 +111,7 @@ func TestMetadataFromStruct(t *testing.T) {
|
||||||
"CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "",
|
"CI_PREV_COMMIT_AUTHOR": "", "CI_PREV_COMMIT_AUTHOR_AVATAR": "", "CI_PREV_COMMIT_AUTHOR_EMAIL": "", "CI_PREV_COMMIT_BRANCH": "",
|
||||||
"CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0",
|
"CI_PREV_COMMIT_MESSAGE": "", "CI_PREV_COMMIT_REF": "", "CI_PREV_COMMIT_REFSPEC": "", "CI_PREV_COMMIT_SHA": "", "CI_PREV_COMMIT_URL": "", "CI_PREV_PIPELINE_CREATED": "0",
|
||||||
"CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "2", "CI_PREV_PIPELINE_PARENT": "0",
|
"CI_PREV_PIPELINE_DEPLOY_TARGET": "", "CI_PREV_PIPELINE_EVENT": "", "CI_PREV_PIPELINE_FINISHED": "0", "CI_PREV_PIPELINE_NUMBER": "2", "CI_PREV_PIPELINE_PARENT": "0",
|
||||||
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "", "CI_REPO": "testUser/testRepo", "CI_REPO_CLONE_URL": "https://gitea.com/testUser/testRepo.git",
|
"CI_PREV_PIPELINE_STARTED": "0", "CI_PREV_PIPELINE_STATUS": "", "CI_PREV_PIPELINE_URL": "", "CI_REPO": "testUser/testRepo", "CI_REPO_CLONE_URL": "https://gitea.com/testUser/testRepo.git", "CI_REPO_CLONE_SSH_URL": "git@gitea.com:testUser/testRepo.git",
|
||||||
"CI_REPO_DEFAULT_BRANCH": "main", "CI_REPO_NAME": "testRepo", "CI_REPO_OWNER": "testUser", "CI_REPO_PRIVATE": "true", "CI_REPO_REMOTE_ID": "",
|
"CI_REPO_DEFAULT_BRANCH": "main", "CI_REPO_NAME": "testRepo", "CI_REPO_OWNER": "testUser", "CI_REPO_PRIVATE": "true", "CI_REPO_REMOTE_ID": "",
|
||||||
"CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_URL": "https://gitea.com/testUser/testRepo", "CI_STEP_FINISHED": "",
|
"CI_REPO_SCM": "git", "CI_REPO_TRUSTED": "false", "CI_REPO_URL": "https://gitea.com/testUser/testRepo", "CI_STEP_FINISHED": "",
|
||||||
"CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_STATUS": "", "CI_SYSTEM_HOST": "example.com",
|
"CI_STEP_NAME": "", "CI_STEP_NUMBER": "0", "CI_STEP_STARTED": "", "CI_STEP_STATUS": "", "CI_SYSTEM_HOST": "example.com",
|
||||||
|
|
|
@ -52,6 +52,7 @@ func convertRepo(from *internal.Repo, perm *internal.RepoPerm) *model.Repo {
|
||||||
repo := model.Repo{
|
repo := model.Repo{
|
||||||
ForgeRemoteID: model.ForgeRemoteID(from.UUID),
|
ForgeRemoteID: model.ForgeRemoteID(from.UUID),
|
||||||
Clone: cloneLink(from),
|
Clone: cloneLink(from),
|
||||||
|
CloneSSH: sshCloneLink(from),
|
||||||
Owner: strings.Split(from.FullName, "/")[0],
|
Owner: strings.Split(from.FullName, "/")[0],
|
||||||
Name: strings.Split(from.FullName, "/")[1],
|
Name: strings.Split(from.FullName, "/")[1],
|
||||||
FullName: from.FullName,
|
FullName: from.FullName,
|
||||||
|
@ -114,6 +115,18 @@ func cloneLink(repo *internal.Repo) string {
|
||||||
return clone
|
return clone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cloneLink is a helper function that tries to extract the clone url from the
|
||||||
|
// repository object.
|
||||||
|
func sshCloneLink(repo *internal.Repo) string {
|
||||||
|
for _, link := range repo.Links.Clone {
|
||||||
|
if link.Name == "ssh" {
|
||||||
|
return link.Href
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// convertUser is a helper function used to convert a Bitbucket user account
|
// convertUser is a helper function used to convert a Bitbucket user account
|
||||||
// structure to the Woodpecker User structure.
|
// structure to the Woodpecker User structure.
|
||||||
func convertUser(from *internal.Account, token *oauth2.Token) *model.User {
|
func convertUser(from *internal.Account, token *oauth2.Token) *model.User {
|
||||||
|
|
|
@ -46,6 +46,7 @@ func toRepo(from *gitea.Repository) *model.Repo {
|
||||||
Link: from.HTMLURL,
|
Link: from.HTMLURL,
|
||||||
IsSCMPrivate: from.Private || from.Owner.Visibility != gitea.VisibleTypePublic,
|
IsSCMPrivate: from.Private || from.Owner.Visibility != gitea.VisibleTypePublic,
|
||||||
Clone: from.CloneURL,
|
Clone: from.CloneURL,
|
||||||
|
CloneSSH: from.SSHURL,
|
||||||
Branch: from.DefaultBranch,
|
Branch: from.DefaultBranch,
|
||||||
Perm: toPerm(from.Permissions),
|
Perm: toPerm(from.Permissions),
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ func convertRepo(from *github.Repository) *model.Repo {
|
||||||
Link: from.GetHTMLURL(),
|
Link: from.GetHTMLURL(),
|
||||||
IsSCMPrivate: from.GetPrivate(),
|
IsSCMPrivate: from.GetPrivate(),
|
||||||
Clone: from.GetCloneURL(),
|
Clone: from.GetCloneURL(),
|
||||||
|
CloneSSH: from.GetSSHURL(),
|
||||||
Branch: from.GetDefaultBranch(),
|
Branch: from.GetDefaultBranch(),
|
||||||
Owner: from.GetOwner().GetLogin(),
|
Owner: from.GetOwner().GetLogin(),
|
||||||
Avatar: from.GetOwner().GetAvatarURL(),
|
Avatar: from.GetOwner().GetAvatarURL(),
|
||||||
|
@ -148,6 +149,7 @@ func convertRepoHook(eventRepo *github.PushEventRepository) *model.Repo {
|
||||||
Link: eventRepo.GetHTMLURL(),
|
Link: eventRepo.GetHTMLURL(),
|
||||||
IsSCMPrivate: eventRepo.GetPrivate(),
|
IsSCMPrivate: eventRepo.GetPrivate(),
|
||||||
Clone: eventRepo.GetCloneURL(),
|
Clone: eventRepo.GetCloneURL(),
|
||||||
|
CloneSSH: eventRepo.GetSSHURL(),
|
||||||
Branch: eventRepo.GetDefaultBranch(),
|
Branch: eventRepo.GetDefaultBranch(),
|
||||||
SCMKind: model.RepoGit,
|
SCMKind: model.RepoGit,
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ func (g *GitLab) convertGitLabRepo(_repo *gitlab.Project) (*model.Repo, error) {
|
||||||
Avatar: _repo.AvatarURL,
|
Avatar: _repo.AvatarURL,
|
||||||
Link: _repo.WebURL,
|
Link: _repo.WebURL,
|
||||||
Clone: _repo.HTTPURLToRepo,
|
Clone: _repo.HTTPURLToRepo,
|
||||||
|
CloneSSH: _repo.SSHURLToRepo,
|
||||||
Branch: _repo.DefaultBranch,
|
Branch: _repo.DefaultBranch,
|
||||||
Visibility: model.RepoVisibility(_repo.Visibility),
|
Visibility: model.RepoVisibility(_repo.Visibility),
|
||||||
IsSCMPrivate: !_repo.Public,
|
IsSCMPrivate: !_repo.Public,
|
||||||
|
@ -96,6 +97,11 @@ func convertMergeRequestHook(hook *gitlab.MergeEvent, req *http.Request) (int, *
|
||||||
} else {
|
} else {
|
||||||
repo.Clone = target.HTTPURL
|
repo.Clone = target.HTTPURL
|
||||||
}
|
}
|
||||||
|
if target.GitSSHURL != "" {
|
||||||
|
repo.CloneSSH = target.GitSSHURL
|
||||||
|
} else {
|
||||||
|
repo.CloneSSH = target.SSHURL
|
||||||
|
}
|
||||||
|
|
||||||
repo.Branch = target.DefaultBranch
|
repo.Branch = target.DefaultBranch
|
||||||
|
|
||||||
|
@ -143,6 +149,7 @@ func convertPushHook(hook *gitlab.PushEvent) (*model.Repo, *model.Pipeline, erro
|
||||||
repo.Avatar = hook.Project.AvatarURL
|
repo.Avatar = hook.Project.AvatarURL
|
||||||
repo.Link = hook.Project.WebURL
|
repo.Link = hook.Project.WebURL
|
||||||
repo.Clone = hook.Project.GitHTTPURL
|
repo.Clone = hook.Project.GitHTTPURL
|
||||||
|
repo.CloneSSH = hook.Project.GitSSHURL
|
||||||
repo.FullName = hook.Project.PathWithNamespace
|
repo.FullName = hook.Project.PathWithNamespace
|
||||||
repo.Branch = hook.Project.DefaultBranch
|
repo.Branch = hook.Project.DefaultBranch
|
||||||
|
|
||||||
|
@ -195,6 +202,7 @@ func convertTagHook(hook *gitlab.TagEvent) (*model.Repo, *model.Pipeline, error)
|
||||||
repo.Avatar = hook.Project.AvatarURL
|
repo.Avatar = hook.Project.AvatarURL
|
||||||
repo.Link = hook.Project.WebURL
|
repo.Link = hook.Project.WebURL
|
||||||
repo.Clone = hook.Project.GitHTTPURL
|
repo.Clone = hook.Project.GitHTTPURL
|
||||||
|
repo.CloneSSH = hook.Project.GitSSHURL
|
||||||
repo.FullName = hook.Project.PathWithNamespace
|
repo.FullName = hook.Project.PathWithNamespace
|
||||||
repo.Branch = hook.Project.DefaultBranch
|
repo.Branch = hook.Project.DefaultBranch
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ type Repo struct {
|
||||||
Avatar string `json:"avatar_url,omitempty" xorm:"varchar(500) 'repo_avatar'"`
|
Avatar string `json:"avatar_url,omitempty" xorm:"varchar(500) 'repo_avatar'"`
|
||||||
Link string `json:"link_url,omitempty" xorm:"varchar(1000) 'repo_link'"`
|
Link string `json:"link_url,omitempty" xorm:"varchar(1000) 'repo_link'"`
|
||||||
Clone string `json:"clone_url,omitempty" xorm:"varchar(1000) 'repo_clone'"`
|
Clone string `json:"clone_url,omitempty" xorm:"varchar(1000) 'repo_clone'"`
|
||||||
|
CloneSSH string `json:"clone_url_ssh" xorm:"varchar(1000) 'repo_clone_ssh'"`
|
||||||
Branch string `json:"default_branch,omitempty" xorm:"varchar(500) 'repo_branch'"`
|
Branch string `json:"default_branch,omitempty" xorm:"varchar(500) 'repo_branch'"`
|
||||||
SCMKind SCMKind `json:"scm,omitempty" xorm:"varchar(50) 'repo_scm'"`
|
SCMKind SCMKind `json:"scm,omitempty" xorm:"varchar(50) 'repo_scm'"`
|
||||||
Timeout int64 `json:"timeout,omitempty" xorm:"repo_timeout"`
|
Timeout int64 `json:"timeout,omitempty" xorm:"repo_timeout"`
|
||||||
|
@ -87,6 +88,9 @@ func (r *Repo) Update(from *Repo) {
|
||||||
if len(from.Clone) > 0 {
|
if len(from.Clone) > 0 {
|
||||||
r.Clone = from.Clone
|
r.Clone = from.Clone
|
||||||
}
|
}
|
||||||
|
if len(from.CloneSSH) > 0 {
|
||||||
|
r.CloneSSH = from.CloneSSH
|
||||||
|
}
|
||||||
r.Branch = from.Branch
|
r.Branch = from.Branch
|
||||||
if from.IsSCMPrivate != r.IsSCMPrivate {
|
if from.IsSCMPrivate != r.IsSCMPrivate {
|
||||||
if from.IsSCMPrivate {
|
if from.IsSCMPrivate {
|
||||||
|
|
Loading…
Reference in a new issue