This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 48c29eee1 fix: gitlab deployment api by order_by=updated_at or
order_by=created_at (#6386)
48c29eee1 is described below
commit 48c29eee1645ce3d3c10c693deda88acd7189565
Author: abeizn <[email protected]>
AuthorDate: Wed Nov 1 22:28:17 2023 -0500
fix: gitlab deployment api by order_by=updated_at or order_by=created_at
(#6386)
---
backend/plugins/gitlab/tasks/deployment_collector.go | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/backend/plugins/gitlab/tasks/deployment_collector.go
b/backend/plugins/gitlab/tasks/deployment_collector.go
index 89c86721a..b7d2a4c69 100644
--- a/backend/plugins/gitlab/tasks/deployment_collector.go
+++ b/backend/plugins/gitlab/tasks/deployment_collector.go
@@ -18,11 +18,14 @@ limitations under the License.
package tasks
import (
+ "net/url"
+ "time"
+
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "net/url"
- "time"
+ "github.com/apache/incubator-devlake/plugins/gitlab/models"
+ "golang.org/x/mod/semver"
)
var _ plugin.SubTaskEntryPoint = CollectDeployment
@@ -62,7 +65,11 @@ func CollectDeployment(taskCtx plugin.SubTaskContext)
errors.Error {
}
// https://gitlab.com/gitlab-org/gitlab/-/issues/328500
//
https://docs.gitlab.com/ee/api/deployments.html#list-project-deployments
- query.Set("order_by", "updated_at")
+ if
semver.Compare(data.ApiClient.GetData(models.GitlabApiClientData_ApiVersion).(string),
"v16.0") >= 0 {
+ query.Set("order_by", "updated_at")
+ } else {
+ query.Set("order_by", "created_at")
+ }
if collectorWithState.Since != nil {
query.Set("updated_after",
collectorWithState.Since.Format(time.RFC3339))
}