summaryrefslogtreecommitdiff
path: root/lib/api/projects.rb
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-04-17 21:04:43 +0300
committerValery Sizov <vsv2711@gmail.com>2015-04-21 19:24:53 +0300
commitf876234f92f868ee34038865521d86e1ebb3ae22 (patch)
tree81246cd7f61a07c918cdd8ebca19e281a539bec4 /lib/api/projects.rb
parentb3e2939aa2904c92aba0399d511cb05228bfc9be (diff)
downloadgitlab-ci-f876234f92f868ee34038865521d86e1ebb3ae22.tar.gz
API for deploy jobs
Diffstat (limited to 'lib/api/projects.rb')
-rw-r--r--lib/api/projects.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index ea10a82..38c8c1b 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -83,6 +83,45 @@ module API
end
end
+ # Add a new deploy job to a project
+ #
+ # Parameters
+ # id (required) - The ID of a project
+ # name (required) - The job name
+ # commands (required) - The command line script for the job
+ # active (optional) - The command is active of not
+ # refs (optional) - The list of refs
+ # tags (optional) - The tags associated with this job
+ # Example Request
+ # POST /projects/:id/deploy_jobs
+ post ":id/deploy_jobs" do
+ required_attributes! [:name, :commands]
+
+ project = Project.find(params[:id])
+
+ not_found! if project.blank?
+ unauthorized! unless current_user.can_manage_project?(project.gitlab_id)
+
+ job_params =
+ {
+ name: params[:name],
+ commands: params[:commands],
+ job_type: "deploy"
+ }
+
+ job_params[:active] = params[:active] unless params[:active].nil?
+ job_params[:refs] = params[:refs] unless params[:refs].nil?
+ job_params[:tag_list] = params[:tags] unless params[:tags].nil?
+
+ job = project.jobs.new(job_params)
+ if job.save
+ present job, with: Entities::DeployJob
+ else
+ errors = job.errors.full_messages.join(", ")
+ render_api_error!(errors, 400)
+ end
+ end
+
# Delete a job for a project
#
# Parameters