-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement GetFiles Func of Bitbucket Server Provider for CEL
implemented GetFiles func of Bitbucket server which lists changed files on an event. it also solves the issue in Bitbucket server where pathChanged() function in CEL expression was not working because the func was not implemented. this does slove the issue. https://issues.redhat.com/browse/SRVKP-5834 Signed-off-by: Zaki Shaikh <[email protected]>
- Loading branch information
Showing
6 changed files
with
371 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package test | ||
|
||
type Pagination struct { | ||
Start int `json:"start"` | ||
Size int `json:"size"` | ||
Limit int `json:"limit"` | ||
LastPage bool `json:"isLastPage"` | ||
NextPage int `json:"nextPageStart"` | ||
} | ||
|
||
type DiffPath struct { | ||
ToString string `json:"toString"` | ||
} | ||
|
||
type DiffStat struct { | ||
Path DiffPath `json:"path"` | ||
SrcPath *DiffPath `json:"srcPath,omitempty"` // used in lib that's why leaving it here nil | ||
Type string `json:"type"` | ||
} | ||
|
||
type DiffStats struct { | ||
Pagination | ||
Values []*DiffStat | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/openshift-pipelines/pipelines-as-code/pkg/params/triggertype" | ||
tbbs "github.com/openshift-pipelines/pipelines-as-code/test/pkg/bitbucketserver" | ||
"github.com/openshift-pipelines/pipelines-as-code/test/pkg/payload" | ||
"github.com/openshift-pipelines/pipelines-as-code/test/pkg/scm" | ||
"github.com/openshift-pipelines/pipelines-as-code/test/pkg/wait" | ||
|
||
"github.com/tektoncd/pipeline/pkg/names" | ||
"gotest.tools/v3/assert" | ||
) | ||
|
||
func TestBitbucketServerCELPathChangeOnPush(t *testing.T) { | ||
targetNS := names.SimpleNameGenerator.RestrictLengthWithRandomSuffix("pac-e2e-ns") | ||
ctx := context.Background() | ||
bitbucketWSOwner := os.Getenv("TEST_BITBUCKET_SERVER_E2E_REPOSITORY") | ||
|
||
ctx, runcnx, opts, client, err := tbbs.Setup(ctx) | ||
assert.NilError(t, err) | ||
|
||
repo := tbbs.CreateCRD(ctx, t, client, runcnx, bitbucketWSOwner, targetNS) | ||
runcnx.Clients.Log.Infof("Repository %s has been created", repo.Name) | ||
defer tbbs.TearDownNs(ctx, t, runcnx, targetNS) | ||
|
||
files := map[string]string{ | ||
".tekton/pipelinerun.yaml": "testdata/pipelinerun-cel-path-changed.yaml", | ||
} | ||
|
||
mainBranchRef := "refs/heads/main" | ||
branch, resp, err := client.Git.CreateRef(ctx, bitbucketWSOwner, targetNS, mainBranchRef) | ||
assert.NilError(t, err, "error creating branch: http status code: %d : %v", resp.Status, err) | ||
runcnx.Clients.Log.Infof("Branch %s has been created", branch.Name) | ||
defer tbbs.TearDown(ctx, t, runcnx, client, -1, bitbucketWSOwner, branch.Name) | ||
|
||
files, err = payload.GetEntries(files, targetNS, branch.Name, triggertype.Push.String(), map[string]string{}) | ||
assert.NilError(t, err) | ||
gitCloneURL, err := scm.MakeGitCloneURL(repo.Clone, opts.UserName, opts.Password) | ||
assert.NilError(t, err) | ||
scmOpts := &scm.Opts{ | ||
GitURL: gitCloneURL, | ||
Log: runcnx.Clients.Log, | ||
WebURL: repo.Clone, | ||
TargetRefName: targetNS, | ||
BaseRefName: repo.Branch, | ||
CommitTitle: fmt.Sprintf("commit %s", targetNS), | ||
} | ||
scm.PushFilesToRefGit(t, scmOpts, files) | ||
runcnx.Clients.Log.Infof("Branch %s has been created and pushed with files", targetNS) | ||
|
||
successOpts := wait.SuccessOpt{ | ||
TargetNS: targetNS, | ||
OnEvent: triggertype.Push.String(), | ||
NumberofPRMatch: 1, | ||
MinNumberStatus: 1, | ||
} | ||
wait.Succeeded(ctx, t, runcnx, opts, successOpts) | ||
} |
Oops, something went wrong.