summaryrefslogtreecommitdiff
path: root/docs/gl_objects/deployments.rst
blob: 9c810ceb6819dbf13087664a621f1f892500fd50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
###########
Deployments
###########

Reference
---------

* v4 API:

  + :class:`gitlab.v4.objects.ProjectDeployment`
  + :class:`gitlab.v4.objects.ProjectDeploymentManager`
  + :attr:`gitlab.v4.objects.Project.deployments`

* GitLab API: https://docs.gitlab.com/ce/api/deployments.html

Examples
--------

List deployments for a project::

    deployments = project.deployments.list()

Get a single deployment::

    deployment = project.deployments.get(deployment_id)

Create a new deployment::

    deployment = project.deployments.create({
        "environment": "Test",
        "sha": "1agf4gs",
        "ref": "main",
        "tag": False,
        "status": "created",
    })

Update a deployment::

    deployment = project.deployments.get(42)
    deployment.status = "failed"
    deployment.save()

Approve a deployment::

    deployment = project.deployments.get(42)
    # `status` must be either "approved" or "rejected".
    deployment.approval(status="approved")

Reject a deployment::

    deployment = project.deployments.get(42)
    # Using the optional `comment` and `represented_as` arguments
    deployment.approval(status="rejected", comment="Fails CI", represented_as="security")

Merge requests associated with a deployment
===========================================

Reference
----------

* v4 API:

  + :class:`gitlab.v4.objects.ProjectDeploymentMergeRequest`
  + :class:`gitlab.v4.objects.ProjectDeploymentMergeRequestManager`
  + :attr:`gitlab.v4.objects.ProjectDeployment.mergerequests`

* GitLab API: https://docs.gitlab.com/ee/api/deployments.html#list-of-merge-requests-associated-with-a-deployment

Examples
--------

List the merge requests associated with a deployment::

    deployment = project.deployments.get(42, lazy=True)
    mrs = deployment.mergerequests.list()