|
@@ 35-45 (lines=11) @@
|
| 32 |
|
return $this->input->getOption('crap4j'); |
| 33 |
|
} |
| 34 |
|
|
| 35 |
|
public function getGitlabApiToken() : string |
| 36 |
|
{ |
| 37 |
|
$gitlabApiToken = $this->input->getOption('gitlab-api-token'); |
| 38 |
|
if ($gitlabApiToken === null) { |
| 39 |
|
$gitlabApiToken = getenv('GITLAB_API_TOKEN'); |
| 40 |
|
if ($gitlabApiToken === false) { |
| 41 |
|
throw new \RuntimeException('Could not find the Gitlab API token in the "GITLAB_API_TOKEN" environment variable. Either set this environment variable or pass the token via the --gitlab-api-token command line option.'); |
| 42 |
|
} |
| 43 |
|
} |
| 44 |
|
return $gitlabApiToken; |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
public function getGitlabUrl() : string |
| 48 |
|
{ |
|
@@ 82-94 (lines=13) @@
|
| 79 |
|
return $projectName; |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
public function getCommitSha() : string |
| 83 |
|
{ |
| 84 |
|
$commitSha = $this->input->getOption('commit-sha'); |
| 85 |
|
|
| 86 |
|
if ($commitSha === null) { |
| 87 |
|
$commitSha = getenv('CI_COMMIT_SHA'); |
| 88 |
|
if ($commitSha === false) { |
| 89 |
|
throw new \RuntimeException('Could not find the Gitlab build reference in the "CI_COMMIT_SHA" environment variable (usually set by Gitlab CI). Either set this environment variable or pass the build reference via the --commit-sha command line option.'); |
| 90 |
|
} |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
return $commitSha; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
public function getJobStage() : string |
| 97 |
|
{ |
|
@@ 96-108 (lines=13) @@
|
| 93 |
|
return $commitSha; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
public function getJobStage() : string |
| 97 |
|
{ |
| 98 |
|
$commitSha = $this->input->getOption('job-stage'); |
| 99 |
|
|
| 100 |
|
if ($commitSha === null) { |
| 101 |
|
$commitSha = getenv('CI_JOB_STAGE'); |
| 102 |
|
if ($commitSha === false) { |
| 103 |
|
throw new \RuntimeException('Could not find the Gitlab job stage in the "CI_JOB_STAGE" environment variable (usually set by Gitlab CI). Either set this environment variable or pass the job stage via the --job_stage command line option.'); |
| 104 |
|
} |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
return $commitSha; |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
public function getGitlabJobId() : int |
| 111 |
|
{ |
|
@@ 110-120 (lines=11) @@
|
| 107 |
|
return $commitSha; |
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
public function getGitlabJobId() : int |
| 111 |
|
{ |
| 112 |
|
$buildId = $this->input->getOption('gitlab-job-id'); |
| 113 |
|
if ($buildId === null) { |
| 114 |
|
$buildId = getenv('CI_JOB_ID'); |
| 115 |
|
if ($buildId === false) { |
| 116 |
|
throw new \RuntimeException('Could not find the Gitlab build id in the "CI_JOB_ID" environment variable (usually set by Gitlab CI). Either set this environment variable or pass the build id via the --gitlab-job-id command line option.'); |
| 117 |
|
} |
| 118 |
|
} |
| 119 |
|
return $buildId; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
public function getGitlabBuildName() : string |
| 123 |
|
{ |
|
@@ 122-132 (lines=11) @@
|
| 119 |
|
return $buildId; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
public function getGitlabBuildName() : string |
| 123 |
|
{ |
| 124 |
|
$buildName = $this->input->getOption('gitlab-build-name'); |
| 125 |
|
if ($buildName === null) { |
| 126 |
|
$buildName = getenv('CI_BUILD_NAME'); |
| 127 |
|
if ($buildName === false) { |
| 128 |
|
throw new \RuntimeException('Could not find the Gitlab build name in the "CI_BUILD_NAME" environment variable (usually set by Gitlab CI). Either set this environment variable or pass the build id via the --gitlab-build-name command line option.'); |
| 129 |
|
} |
| 130 |
|
} |
| 131 |
|
return $buildName; |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
/** |
| 135 |
|
* Returns the current branch name (from Git) |