summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-05-03 18:33:03 +0100
committerFilipa Lacerda <filipa@gitlab.com>2017-05-03 18:33:03 +0100
commit2b075561f9213530d1911bea875c5ed9ac42b1a6 (patch)
tree2d72260c7c5947dea390a97f4f444b191a6079c1 /lib
parenta5989900c9c001eaee971969b89a708f132c6d7c (diff)
parente14ca5394edf0497184415f12629dfdbe72a2727 (diff)
downloadgitlab-ce-31156-environments-vue-service.tar.gz
Merge branch 'master' into 31156-environments-vue-service31156-environments-vue-service
* master: (91 commits) Move api lint out of static analysis job Fix project tree saver and fork spec failures Fix lazy error handling of cron parser Use gitlab-workhorse 2.0.0 Revert to real click seeing as that was a bug with only the original branch Fixed issue_sidebar_spec.rb click as true click cannot hit the right element and removed sleep find and match first dropdown before clicking Elaborate on the usage of Spring Note Ghost user and refer to user deletion documentation Fix label creation from issuable for subgroup projects Detect already enabled DeployKeys in EnableDeployKeyService Extract common parts of snippet and blob pages into partial update article date link ldap-ee article from auth index add ldap article and changes from !10299 Fix misaligned buttons in wiki pages Improve pipelines_finder.rb Improve documentation Correct typo in pipelines_spec.rb Avoid using sample ...
Diffstat (limited to 'lib')
-rw-r--r--lib/api/pipelines.rb16
-rw-r--r--lib/api/v3/pipelines.rb2
-rw-r--r--lib/gitlab/ci/cron_parser.rb19
-rw-r--r--lib/gitlab/import_export/import_export.yml1
4 files changed, 32 insertions, 6 deletions
diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb
index 754c3d85a04..9117704aa46 100644
--- a/lib/api/pipelines.rb
+++ b/lib/api/pipelines.rb
@@ -14,13 +14,23 @@ module API
end
params do
use :pagination
- optional :scope, type: String, values: %w(running branches tags),
- desc: 'Either running, branches, or tags'
+ optional :scope, type: String, values: %w[running pending finished branches tags],
+ desc: 'The scope of pipelines'
+ optional :status, type: String, values: HasStatus::AVAILABLE_STATUSES,
+ desc: 'The status of pipelines'
+ optional :ref, type: String, desc: 'The ref of pipelines'
+ optional :yaml_errors, type: Boolean, desc: 'Returns pipelines with invalid configurations'
+ optional :name, type: String, desc: 'The name of the user who triggered pipelines'
+ optional :username, type: String, desc: 'The username of the user who triggered pipelines'
+ optional :order_by, type: String, values: PipelinesFinder::ALLOWED_INDEXED_COLUMNS, default: 'id',
+ desc: 'Order pipelines'
+ optional :sort, type: String, values: %w[asc desc], default: 'desc',
+ desc: 'Sort pipelines'
end
get ':id/pipelines' do
authorize! :read_pipeline, user_project
- pipelines = PipelinesFinder.new(user_project).execute(scope: params[:scope])
+ pipelines = PipelinesFinder.new(user_project, params).execute
present paginate(pipelines), with: Entities::PipelineBasic
end
diff --git a/lib/api/v3/pipelines.rb b/lib/api/v3/pipelines.rb
index 82827249244..c48cbd2b765 100644
--- a/lib/api/v3/pipelines.rb
+++ b/lib/api/v3/pipelines.rb
@@ -21,7 +21,7 @@ module API
get ':id/pipelines' do
authorize! :read_pipeline, user_project
- pipelines = PipelinesFinder.new(user_project).execute(scope: params[:scope])
+ pipelines = PipelinesFinder.new(user_project, scope: params[:scope]).execute
present paginate(pipelines), with: ::API::Entities::Pipeline
end
end
diff --git a/lib/gitlab/ci/cron_parser.rb b/lib/gitlab/ci/cron_parser.rb
index a3cc350ef22..dad8c3cdf5b 100644
--- a/lib/gitlab/ci/cron_parser.rb
+++ b/lib/gitlab/ci/cron_parser.rb
@@ -6,7 +6,7 @@ module Gitlab
def initialize(cron, cron_timezone = 'UTC')
@cron = cron
- @cron_timezone = cron_timezone
+ @cron_timezone = ActiveSupport::TimeZone.find_tzinfo(cron_timezone).name
end
def next_time_from(time)
@@ -24,8 +24,23 @@ module Gitlab
private
+ # NOTE:
+ # cron_timezone can only accept timezones listed in TZInfo::Timezone.
+ # Aliases of Timezones from ActiveSupport::TimeZone are NOT accepted,
+ # because Rufus::Scheduler only supports TZInfo::Timezone.
+ #
+ # For example, those codes have the same effect.
+ # Time.zone = 'Pacific Time (US & Canada)' (ActiveSupport::TimeZone)
+ # Time.zone = 'America/Los_Angeles' (TZInfo::Timezone)
+ #
+ # However, try_parse_cron only accepts the latter format.
+ # try_parse_cron('* * * * *', 'Pacific Time (US & Canada)') -> Doesn't work
+ # try_parse_cron('* * * * *', 'America/Los_Angeles') -> Works
+ # If you want to know more, please take a look
+ # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/values/time_zone.rb
def try_parse_cron(cron, cron_timezone)
- Rufus::Scheduler.parse("#{cron} #{cron_timezone}")
+ cron_line = Rufus::Scheduler.parse("#{cron} #{cron_timezone}")
+ cron_line if cron_line.is_a?(Rufus::Scheduler::CronLine)
rescue
# noop
end
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml
index b95cea371b9..3aac731e844 100644
--- a/lib/gitlab/import_export/import_export.yml
+++ b/lib/gitlab/import_export/import_export.yml
@@ -84,6 +84,7 @@ excluded_attributes:
- :import_jid
- :id
- :star_count
+ - :last_activity_at
snippets:
- :expired_at
merge_request_diff: