You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2023/11/02 03:05:15 UTC
(incubator-devlake) branch fix-gitlab-deployment updated: fix: gitlab deployment api by order_by=updated_at or order_by=created_at
This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch fix-gitlab-deployment
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/fix-gitlab-deployment by this push:
new 7dab1aca5 fix: gitlab deployment api by order_by=updated_at or order_by=created_at
7dab1aca5 is described below
commit 7dab1aca506c0e394d7b00096a75c1fe6b386e07
Author: abeizn <zi...@merico.dev>
AuthorDate: Thu Nov 2 11:05:04 2023 +0800
fix: gitlab deployment api by order_by=updated_at or order_by=created_at
---
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))
}