@@ -2,14 +2,14 @@ package jenkins
2
2
3
3
import (
4
4
"fmt"
5
+ "os"
6
+ "strconv"
7
+ "strings"
8
+
5
9
"github.com/aquasecurity/go-git-pr-commenter/pkg/commenter/github"
6
10
"github.com/argonsecurity/go-environments/enums"
7
11
"github.com/argonsecurity/go-environments/environments/jenkins"
8
12
env_utils "github.com/argonsecurity/go-environments/environments/utils"
9
- "net/url"
10
- "os"
11
- "strconv"
12
- "strings"
13
13
14
14
"github.com/aquasecurity/go-git-pr-commenter/pkg/commenter"
15
15
"github.com/aquasecurity/go-git-pr-commenter/pkg/commenter/bitbucket"
@@ -37,11 +37,7 @@ func NewJenkins(baseRef string) (commenter.Repository, error) {
37
37
} else { // bitbucket server
38
38
repoName := bitbucketutils .GetRepositoryName (cloneUrl )
39
39
project , repo := bitbucketutils .GetProjectAndRepo (repoName )
40
- apiUrl , err := getBaseUrl (cloneUrl )
41
- if err != nil {
42
- return nil , err
43
- }
44
- return bitbucket_server .NewBitbucketServer (apiUrl , username , password , bitbucketutils .GetPrId (), project , repo , baseRef )
40
+ return bitbucket_server .NewBitbucketServer (scmApiUrl , username , password , bitbucketutils .GetPrId (), project , repo , baseRef )
45
41
}
46
42
} else if scmSource == enums .GithubServer || scmSource == enums .Github {
47
43
_ , org , repoName , _ , err := env_utils .ParseDataFromCloneUrl (cloneUrl , scmApiUrl , scmSource )
@@ -66,23 +62,9 @@ func NewJenkins(baseRef string) (commenter.Repository, error) {
66
62
repoName ,
67
63
prNumberInt )
68
64
} else { //github server
69
- apiUrl , err := getBaseUrl (cloneUrl )
70
- if err != nil {
71
- return nil , err
72
- }
73
- return github .NewGithubServer (apiUrl , token , org , repoName , prNumberInt )
65
+ return github .NewGithubServer (scmApiUrl , token , org , repoName , prNumberInt )
74
66
}
75
67
76
68
}
77
-
78
69
return nil , nil
79
70
}
80
-
81
- func getBaseUrl (fullUrl string ) (string , error ) {
82
- u , err := url .Parse (fullUrl )
83
- if err != nil {
84
- return "" , fmt .Errorf ("failed to parse url %s - %s" , fullUrl , err .Error ())
85
- }
86
-
87
- return fmt .Sprintf ("%s://%s" , u .Scheme , u .Host ), nil
88
- }
0 commit comments