Failed Builds Consume a Deployment ID That Cannot Be Queried Via the API
### Summary
When a pipeline fails where a deploy task is set up to deploy to an environment, the Deployment ID # is consumed and skipped in the UI, but does not display in the environment and does not return in an API query to return all Deployment ID's.
### Steps to reproduce
1. Trigger a pipeline that fails during a job before Deploy, resulting in nothing getting deployed to the environments section
2. Query the Deployments IID using the following API call
`https://<gitlabserver>.com/api/v4/projects/<projectID>/deployments?order_by=iid&sort=asc`
### What is the current *bug* behavior?
Currently the deployment ID is consumed via GitLab but cannot be referenced normally through either the UI or API
### What is the expected *correct* behavior?
I have two potential expectations
1.) A pipeline that fails without completing the deploy job should not consume a deployment iid
2.) All deployment iid's should appear in the UI and be queryable through the API
What is causing this to be a problem is we are labeling our artifact information based off of the deployment iid as for our purposes the deployment iid is the best "build number" in our situation. To label the artifacts during the build stage we query all deployment iid's, take the most recent one and increment that number and rename files with that information. When a build fails however, the next successful deployment uses the previous successful deployment iid and increments that, leading to a mismatch in the UI vs the named file. This corrects itself if two builds in a row are successful.
### Relevant logs and/or screenshots

```
[
{
"id": 39603,
"iid": 3,
"ref": "release/IR",
"sha": "cae6eb4140aa4a8124198a486308dcc4b3c2ac51",
"created_at": "2019-05-21T19:14:24.754Z",
"user": {
"id": 136,
"name": "Taylor Horhut",
"username": "thorhut",
"state": "active",
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/136/avatar.png",
"web_url": "https://gitlab.com/thorhut"
},
"environment": {
"id": 824,
"name": "staging",
"slug": "staging",
"external_url": "https://.com"
},
"deployable": {
"id": 184189,
"status": "success",
"stage": "deploy",
"name": "staging",
"ref": "release/IR",
"tag": false,
"coverage": null,
"created_at": "2019-05-21T19:14:24.738Z",
"started_at": "2019-05-21T19:20:32.476Z",
"finished_at": "2019-05-21T19:20:57.700Z",
"duration": 25.223831,
"user": {
"id": 136,
"name": "Taylor Horhut",
"username": "thorhut",
"state": "active",
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/136/avatar.png",
"web_url": "https://gitlab.com/thorhut",
"created_at": "2018-03-28T20:07:03.025Z",
"bio": "",
"location": "",
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
},
"commit": {
"id": "cae6eb4140aa4a8124198a486308dcc4b3c2ac51",
"short_id": "cae6eb41",
"title": "Updated import reference for medModuleConfig",
"created_at": "2019-05-21T19:14:05.000Z",
"parent_ids": [
"c18544706e82e62f1ce8e34c4e57f1ee58983af4"
],
"message": "Updated import reference for medModuleConfig\n\n",
"author_name": "Taylor Horhut",
"author_email": "taylor.horhut@ert.com",
"authored_date": "2019-05-21T19:05:29.000Z",
"committer_name": "Taylor Horhut",
"committer_email": "taylor.horhut@ert.com",
"committed_date": "2019-05-21T19:14:05.000Z"
},
"pipeline": {
"id": 28987,
"sha": "cae6eb4140aa4a8124198a486308dcc4b3c2ac51",
"ref": "release/IR",
"status": "success",
"web_url": ""
},
"web_url": "",
"artifacts_file": {
"filename": "GIT-SYN.zip",
"size": 24267061
},
"artifacts": [
{
"file_type": "archive",
"size": 24267061,
"filename": "GIT-SYN.zip",
"file_format": "zip"
},
{
"file_type": "metadata",
"size": 329,
"filename": "metadata.gz",
"file_format": "gzip"
},
{
"file_type": "trace",
"size": 3416,
"filename": "job.log",
"file_format": null
}
],
"runner": {
"id": 18,
"description": "c1pgitrvap03 Docker runner linux with DiD",
"ip_address": "10.30.119.220",
"active": true,
"is_shared": true,
"name": "gitlab-runner",
"online": true,
"status": "online"
},
"artifacts_expire_at": null
}
},
{
"id": 39949,
"iid": 5,
"ref": "release/IR",
"sha": "06c649c7918458c56a92bde295f512faf4afc168",
"created_at": "2019-05-23T19:40:49.674Z",
"user": {
"id": 136,
"name": "Taylor Horhut",
"username": "thorhut",
"state": "active",
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/136/avatar.png",
"web_url": "https://gitlab.com/thorhut"
},
"environment": {
"id": 824,
"name": "staging",
"slug": "staging",
"external_url": "https://ert.com"
},
"deployable": {
"id": 185364,
"status": "success",
"stage": "deploy",
"name": "staging",
"ref": "release/IR",
"tag": false,
"coverage": null,
"created_at": "2019-05-23T19:40:49.656Z",
"started_at": "2019-05-23T19:47:27.484Z",
"finished_at": "2019-05-23T19:47:49.354Z",
"duration": 21.870813,
"user": {
"id": 136,
"name": "Taylor Horhut",
"username": "thorhut",
"state": "active",
"avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/136/avatar.png",
"web_url": "https://gitlab.com/thorhut",
"created_at": "2018-03-28T20:07:03.025Z",
"bio": "",
"location": "",
"public_email": "",
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": ""
},
"commit": {
"id": "06c649c7918458c56a92bde295f512faf4afc168",
"short_id": "06c649c7",
"title": "import path updated for combMedDataObjects",
"created_at": "2019-05-23T19:40:37.000Z",
"parent_ids": [
"f46dddb4c293c842bc6c8eb8f022f6795cf91f42"
],
"message": "import path updated for combMedDataObjects\n\n",
"author_name": "Taylor Horhut",
"author_email": "taylor.horhut@ert.com",
"authored_date": "2019-05-23T19:40:37.000Z",
"committer_name": "Taylor Horhut",
"committer_email": "taylor.horhut@ert.com",
"committed_date": "2019-05-23T19:40:37.000Z"
},
"pipeline": {
"id": 29182,
"sha": "06c649c7918458c56a92bde295f512faf4afc168",
"ref": "release/IR",
"status": "success",
"web_url": ""
},
"web_url": "",
"artifacts_file": {
"filename": "GIT-SYN.zip",
"size": 24279726
},
"artifacts": [
{
"file_type": "archive",
"size": 24279726,
"filename": "GIT-SYN.zip",
"file_format": "zip"
},
{
"file_type": "metadata",
"size": 326,
"filename": "metadata.gz",
"file_format": "gzip"
},
{
"file_type": "trace",
"size": 3451,
"filename": "job.log",
"file_format": null
}
],
"runner": {
"id": 62,
"description": "c1tgitrvap04 Docker runner linux with DiD",
"ip_address": "10.30.7.180",
"active": true,
"is_shared": true,
"name": "gitlab-runner",
"online": true,
"status": "online"
},
"artifacts_expire_at": null
}
}
]
```
#### Results of GitLab environment info
<details>
<summary>Expand for output related to GitLab environment info</summary>
<pre>
Currently using a custom server implementation of GitLab at version 11.8.7
</pre>
</details>
issue