Completed
Pull Request — 2.0 (#26)
by
unknown
01:53
created

RunCommand::getMeasuresFromCommit()   B

Complexity

Conditions 8
Paths 31

Size

Total Lines 45

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 7.9555
c 0
b 0
f 0
cc 8
nc 31
nop 8

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
namespace TheCodingMachine\WashingMachine\Commands;
3
4
use Gitlab\Client;
5
use Gitlab\Model\Project;
6
use Psr\Log\LoggerInterface;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Logger\ConsoleLogger;
11
use Symfony\Component\Console\Output\OutputInterface;
12
use TheCodingMachine\WashingMachine\Clover\CloverFile;
13
use TheCodingMachine\WashingMachine\Clover\Crap4JFile;
14
use TheCodingMachine\WashingMachine\Clover\CrapMethodMerger;
15
use TheCodingMachine\WashingMachine\Clover\DiffService;
16
use TheCodingMachine\WashingMachine\Clover\EmptyCloverFile;
17
use TheCodingMachine\WashingMachine\Git\GitRepository;
18
use TheCodingMachine\WashingMachine\Gitlab\BuildNotFoundException;
19
use TheCodingMachine\WashingMachine\Gitlab\BuildService;
20
use TheCodingMachine\WashingMachine\Gitlab\MergeRequestNotFoundException;
21
use TheCodingMachine\WashingMachine\Gitlab\Message;
22
use TheCodingMachine\WashingMachine\Gitlab\SendCommentService;
23
24
class RunCommand extends Command
25
{
26
    /**
27
     * @var LoggerInterface
28
     */
29
    private $logger;
30
31
    protected function configure()
32
    {
33
        $this
34
            ->setName('run')
35
            ->setDescription('Analyses the coverage report files and upload the result to Gitlab')
36
            //->setHelp("This command allows you to create users...")
37
            ->addOption('clover',
38
                'c',
39
                InputOption::VALUE_REQUIRED,
40
                'The path to the clover.xml file generated by PHPUnit.',
41
                'clover.xml')
42
            ->addOption('crap4j',
43
                'j',
44
                InputOption::VALUE_REQUIRED,
45
                'The path to the crap4j.xml file generated by PHPUnit.',
46
                'crap4j.xml')
47
            ->addOption('gitlab-url',
48
                'u',
49
                InputOption::VALUE_REQUIRED,
50
                'The Gitlab URL. If not specified, it is deduced from the CI_REPOSITORY_URL environment variable.',
51
                null)
52
            ->addOption('gitlab-api-token',
53
                't',
54
                InputOption::VALUE_REQUIRED,
55
                'The Gitlab API token. If not specified, it is fetched from the GITLAB_API_TOKEN environment variable.',
56
                null)
57
            /*->addOption('gitlab-project-id',
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
58
                'p',
59
                InputOption::VALUE_REQUIRED,
60
                'The Gitlab project ID. If not specified, it is fetched from the CI_PROJECT_ID environment variable.',
61
                null)*/
62
            ->addOption('gitlab-project-name',
63
                'p',
64
                InputOption::VALUE_REQUIRED,
65
                'The Gitlab project name (in the form "group/name"). If not specified, it is deduced from the CI_PROJECT_DIR environment variable.',
66
                null)
67
            ->addOption('commit-sha',
68
                'r',
69
                InputOption::VALUE_REQUIRED,
70
                'The commit SHA. If not specified, it is deduced from the CI_COMMIT_SHA environment variable.',
71
                null)
72
            ->addOption('gitlab-job-id',
73
                'b',
74
                InputOption::VALUE_REQUIRED,
75
                'The Gitlab CI build/job id. If not specified, it is deduced from the CI_JOB_ID environment variable.',
76
                null)
77
            ->addOption('gitlab-build-name',
78
                'a',
79
                InputOption::VALUE_REQUIRED,
80
                'The Gitlab CI build name (the name of this build in the job). If not specified, it is deduced from the CI_BUILD_NAME environment variable.',
81
                null)
82
            ->addOption('gitlab-pipeline-id',
83
                'e',
84
                InputOption::VALUE_REQUIRED,
85
                'The Gitlab CI pipeline ID. If not specified, it is deduced from the CI_PIPELINE_ID environment variable.',
86
                null)
87
            ->addOption('job-stage',
88
                's',
89
                InputOption::VALUE_REQUIRED,
90
                'The Gitlab CI job stage. If not specified, it is deduced from the CI_JOB_STAGE environment variable.',
91
                null)
92
            ->addOption('file',
93
                'f',
94
                InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
95
                'Text file to be sent in the merge request comments (can be used multiple times).',
96
                [])
97
            ->addOption('open-issue',
98
                'i',
99
                InputOption::VALUE_NONE,
100
                'Opens an issue (if the build is not part of a merge request)')
101
            ->addOption('add-comments-in-commits',
102
                null,
103
                InputOption::VALUE_NONE,
104
                'Add comments directly in the commit')
105
        ;
106
    }
107
108
    protected function execute(InputInterface $input, OutputInterface $output)
109
    {
110
        $this->logger = new ConsoleLogger($output);
111
        $config = new Config($input);
112
113
        $cloverFilePath = $config->getCloverFilePath();
114
115
        $cloverFile = null;
116
        if (file_exists($cloverFilePath)) {
117
            $cloverFile = CloverFile::fromFile($cloverFilePath, getcwd());
118
            //$output->writeln(sprintf('Code coverage: %.2f%%', $cloverFile->getCoveragePercentage() * 100));
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
119
        }
120
121
        $crap4JFilePath = $config->getCrap4JFilePath();
122
123
        $crap4jFile = null;
124
        if (file_exists($crap4JFilePath)) {
125
            $crap4jFile = Crap4JFile::fromFile($crap4JFilePath);
126
        }
127
128
        $files = $config->getFiles();
129
130
        $methodsProvider = null;
131
        $codeCoverageProvider = null;
132
133
        if ($cloverFile !== null && $crap4jFile !== null) {
134
            $methodsProvider = new CrapMethodMerger($cloverFile, $crap4jFile);
135
            $codeCoverageProvider = $cloverFile;
136
        } elseif ($cloverFile !== null) {
137
            $methodsProvider = $cloverFile;
138
            $codeCoverageProvider = $cloverFile;
139
        } elseif ($crap4jFile !== null) {
140
            $methodsProvider = $crap4jFile;
141
        } elseif (empty($files)) {
142
            $output->writeln('<error>Could not find neither clover file, nor crap4j file for analysis nor files to send in comments. Nothing done. Searched paths: '.$cloverFilePath.' and '.$crap4JFilePath.'.</error>');
143
            $output->writeln('<comment>You might want to check that your unit tests where run successfully</comment>');
144
            $output->writeln('<comment>Alternatively, maybe you did not run Clover file generation? Use "phpunit --coverage-clover clover.xml"</comment>');
145
            return;
146
        }
147
148
        $gitlabApiToken = $config->getGitlabApiToken();
149
150
        $gitlabUrl = $config->getGitlabUrl();
151
        $gitlabApiUrl = $config->getGitlabApiUrl();
152
153
154
        /*$projectId = $input->getOption('gitlab-project-id');
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
155
        if ($projectId === null) {
156
            $projectId = getenv('CI_PROJECT_ID');
157
            if ($projectId === false) {
158
                throw new \RuntimeException('Could not find the Gitlab project ID in the "CI_PROJECT_ID" environment variable (usually set by Gitlab CI). Either set this environment variable or pass the ID via the --gitlab-project-id command line option.');
159
            }
160
        }*/
161
162
        $projectName = $config->getGitlabProjectName();
163
164
        $commitSha = $config->getCommitSha();
165
166
        $currentBranchName = $config->getCurrentBranchName();
167
168
        $client = Client::create($gitlabApiUrl);
169
        $client->authenticate($gitlabApiToken);
170
171
        $diffService = new DiffService(5, 30, 20);
172
173
        $sendCommentService = new SendCommentService($client, $diffService);
174
175
        // From CI_COMMIT_SHA, we can get the commit ( -> project -> build -> commit )
176
        // From the merge_requests API, we can get the list of commits for a single merge request
177
        // Hence, we can find the merge_request matching a build!
178
179
        $buildService = new BuildService($client, $this->logger);
180
181
        $inMergeRequest = false;
182
183
        try {
184
            $mergeRequest = $buildService->findMergeRequestByCommitSha($projectName, $commitSha);
185
186
            $repo = new GitRepository(getcwd());
187
            $targetCommit = $repo->getLatestCommitForBranch('origin/'.$mergeRequest['target_branch']);
188
            $lastCommonCommit = $repo->getMergeBase($targetCommit, $commitSha);
189
190
            $output->writeln('Pipeline current commit: '.$commitSha, OutputInterface::VERBOSITY_DEBUG);
191
            $output->writeln('Target branch: '.$mergeRequest['target_branch'], OutputInterface::VERBOSITY_DEBUG);
192
            $output->writeln('Target commit: '.$targetCommit, OutputInterface::VERBOSITY_DEBUG);
193
            $output->writeln('Last common commit: '.$lastCommonCommit, OutputInterface::VERBOSITY_DEBUG);
194
195
            list($previousCodeCoverageProvider, $previousMethodsProvider) = $this->getMeasuresFromCommit($buildService, $mergeRequest['target_project_id'], $lastCommonCommit, $cloverFilePath, $crap4JFilePath, $config->getJobStage(), $config->getGitlabBuildName(), null);
196
            //list($previousCodeCoverageProvider, $previousMethodsProvider) = $this->getMeasuresFromBranch($buildService, $mergeRequest['target_project_id'], $mergeRequest['target_branch'], $cloverFilePath, $crap4JFilePath);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
197
198
            $message = new Message();
199
            if ($codeCoverageProvider !== null) {
200
                $message->addCoverageMessage($codeCoverageProvider, $previousCodeCoverageProvider);
201
            } else {
202
                $output->writeln('Could not find clover file for code coverage analysis.');
203
            }
204
            if ($methodsProvider !== null) {
205
                $message->addDifferencesHtml($methodsProvider, $previousMethodsProvider, $diffService, $commitSha, $gitlabUrl, $projectName);
206
            } else {
207
                $output->writeln('Could not find clover file nor crap4j file for CRAP score analysis.');
208
            }
209
210
            $this->addFilesToMessage($message, $files, $output, $config);
211
212
            $client->merge_requests->addNote($projectName, $mergeRequest['iid'], (string) $message);
213
214
            $inMergeRequest = true;
215
        } catch (MergeRequestNotFoundException $e) {
216
            // If there is no merge request attached to this build, let's skip the merge request comment. We can still make some comments on the commit itself!
217
            $output->writeln('It seems that this CI build is not part of a merge request.');
218
        }
219
220
        if ($config->isAddCommentsInCommits() || ($config->isOpenIssue() && !$inMergeRequest)) {
221
            try {
222
                $targetProjectId = $mergeRequest['target_project_id'] ?? $projectName;
223
                list($lastCommitCoverage, $lastCommitMethodsProvider) = $this->getMeasuresFromBranch($buildService, $targetProjectId, $currentBranchName, $cloverFilePath, $crap4JFilePath, $config->getJobStage(), $config->getGitlabBuildName(), $config->getGitlabPipelineId());
224
225
                if ($config->isAddCommentsInCommits()) {
226
                    $sendCommentService->sendDifferencesCommentsInCommit($methodsProvider, $lastCommitMethodsProvider, $projectName, $commitSha, $gitlabUrl);
0 ignored issues
show
Bug introduced by
It seems like $methodsProvider defined by null on line 130 can also be of type null; however, TheCodingMachine\Washing...encesCommentsInCommit() does only seem to accept object<TheCodingMachine\...MethodFetcherInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
227
                }
228
229
                if ($config->isOpenIssue() && !$inMergeRequest) {
230
                    $message = new Message();
231
232
                    if ($codeCoverageProvider !== null) {
233
                        $message->addCoverageMessage($codeCoverageProvider, $lastCommitCoverage);
234
                    } else {
235
                        $output->writeln('Could not find clover file for code coverage analysis.');
236
                    }
237
238
                    if ($methodsProvider !== null) {
239
                        $message->addDifferencesHtml($methodsProvider, $lastCommitMethodsProvider, $diffService, $commitSha, $gitlabUrl, $projectName);
240
                    } else {
241
                        $output->writeln('Could not find clover file nor crap4j file for CRAP score analysis.');
242
                    }
243
244
                    $this->addFilesToMessage($message, $files, $output, $config);
245
246
                    $project = new Project($projectName, $client);
247
248
                    $options = [
249
                        'description' => (string) $message
250
                    ];
251
252
                    $userId = $this->getCommiterId($project, $commitSha);
253
                    if ($userId !== null) {
254
                        $options['assignee_id'] = $userId;
255
                    }
256
257
                    $project->createIssue('Build failed', $options);
258
                }
259
            } catch (BuildNotFoundException $e) {
260
                $output->writeln('Unable to find a previous build for this branch. Skipping adding comments inside the commit. '.$e->getMessage());
261
            }
262
        }
263
    }
264
265
    /**
266
     * Returns the user id of the committer.
267
     *
268
     * @param Project $project
269
     * @param string $commitRef
270
     * @return int|null
271
     */
272
    private function getCommiterId(Project $project, $commitRef)
273
    {
274
275
        $commit = $project->commit($commitRef);
276
277
        return $commit->committer ? $commit->committer->id :  null;
278
    }
279
280
    /**
281
     * @param BuildService $buildService
282
     * @param string $projectName
283
     * @param string $targetBranch
284
     * @param string $cloverPath
285
     * @param string $crap4JPath
286
     * @return array First element: code coverage, second element: list of methods.
287
     * @throws BuildNotFoundException
288
     */
289
    public function getMeasuresFromBranch(BuildService $buildService, string $projectName, string $targetBranch, string $cloverPath, string $crap4JPath, string $jobStage, string $buildName, string $excludePipelineId) : array
290
    {
291
        try {
292
            $tmpFile = tempnam(sys_get_temp_dir(), 'art').'.zip';
293
294
            $buildService->dumpArtifactFromBranch($projectName, $targetBranch, $buildName, $jobStage, $tmpFile, $excludePipelineId);
295
            $zipFile = new \ZipArchive();
296
            if ($zipFile->open($tmpFile)!==true) {
297
                throw new \RuntimeException('Invalid ZIP archive '.$tmpFile);
298
            }
299
            return $this->getMeasuresFromZipFile($zipFile, $cloverPath, $crap4JPath);
300
        } catch (\RuntimeException $e) {
301
            if ($e->getCode() === 404) {
302
                // We could not find a previous clover file in the master branch.
303
                // Maybe this branch is the first to contain clover files?
304
                // Let's deal with this by generating a fake "empty" clover file.
305
                $this->logger->info('We could not find a previous clover file in the build attached to branch '.$targetBranch.'. Maybe this commit is the first on this branch?');
306
                return [EmptyCloverFile::create(), EmptyCloverFile::create()];
307
            } else {
308
                throw $e;
309
            }
310
        }
311
    }
312
313
    public function getMeasuresFromCommit(BuildService $buildService, string $projectName, string $commitId, string $cloverPath, string $crap4JPath, string $jobStage, string $buildName, ?string $excludePipelineId) : array
314
    {
315
        try {
316
            $tmpFile = tempnam(sys_get_temp_dir(), 'art').'.zip';
317
318
            $pipeline = $buildService->getLatestPipelineFromCommitId($projectName, $commitId, $excludePipelineId);
319
            $buildService->dumpArtifact($projectName, $pipeline['id'], $buildName, $jobStage, $tmpFile);
320
            $zipFile = new \ZipArchive();
321
            $result = $zipFile->open($tmpFile);
322
            if ($result !== true) {
323
                switch ($result) {
324
                    case 9:
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
325
                        throw new \RuntimeException("An error occurred while unzipping artifact from commit $commitId. Error code $result: No such file");
326
                        break;
0 ignored issues
show
Unused Code introduced by
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
327
                    case 11:
328
                        throw new \RuntimeException("An error occurred while unzipping artifact from commit $commitId. Error code $result: Can't open file");
329
                        break;
0 ignored issues
show
Unused Code introduced by
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
330
                    case 19:
331
                        throw new \RuntimeException("An error occurred while unzipping artifact from commit $commitId. Error code $result: Not a zip archive");
332
                        break;
0 ignored issues
show
Unused Code introduced by
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
333
                    default:
334
                        throw new \RuntimeException("An error occurred while unzipping artifact from commit $commitId. Error code $result: ".$zipFile->getStatusString());
335
                        break;
0 ignored issues
show
Unused Code introduced by
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
336
                }
337
            }
338
            return $this->getMeasuresFromZipFile($zipFile, $cloverPath, $crap4JPath);
339
        } catch (\RuntimeException $e) {
340
            if ($e->getCode() === 404) {
341
                // We could not find a previous clover file in the given commit.
342
                // Maybe this branch is the first to contain clover files?
343
                // Let's deal with this by generating a fake "empty" clover file.
344
                $this->logger->warning('We could not find a previous clover file in the build attached to commit '.$commitId.'. Maybe this branch is the first to contain clover files?');
345
                $this->logger->debug($e->getMessage().' - '.$e->getTraceAsString(), [
346
                    'exception' => $e
347
                ]);
348
                return [EmptyCloverFile::create(), EmptyCloverFile::create()];
349
            } else {
350
                throw $e;
351
            }
352
        } catch (BuildNotFoundException $e) {
353
            // Maybe there is no .gitlab-ci.yml file on the target branch? In this case, there is no build.
354
            $this->logger->warning('We could not find a build for commit '.$commitId.'.');
355
            return [EmptyCloverFile::create(), EmptyCloverFile::create()];
356
        }
357
    }
358
359
    private function getMeasuresFromZipFile(\ZipArchive $zipFile, string $cloverPath, string $crap4JPath) : array
360
    {
361
        $cloverFileString = $zipFile->getFromName($cloverPath);
362
363
        $cloverFile = null;
364
        if ($cloverFileString !== false) {
365
            $cloverFile = CloverFile::fromString($cloverFileString, getcwd());
366
        }
367
368
        $crap4JString = $zipFile->getFromName($crap4JPath);
369
370
        $crap4JFile = null;
371
        if ($crap4JString !== false) {
372
            $crap4JFile = Crap4JFile::fromString($crap4JString);
373
        }
374
375
        $methodsProvider = null;
0 ignored issues
show
Unused Code introduced by
$methodsProvider is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
376
        $codeCoverageProvider = null;
377
378
        if ($cloverFile !== null && $crap4JFile !== null) {
379
            $methodsProvider = new CrapMethodMerger($cloverFile, $crap4JFile);
380
            $codeCoverageProvider = $cloverFile;
381
        } elseif ($cloverFile !== null) {
382
            $methodsProvider = $cloverFile;
383
            $codeCoverageProvider = $cloverFile;
384
        } elseif ($crap4JFile !== null) {
385
            $methodsProvider = $crap4JFile;
386
        } else {
387
            return [EmptyCloverFile::create(), EmptyCloverFile::create()];
388
        }
389
390
        return [$codeCoverageProvider, $methodsProvider];
391
    }
392
393
    private function addFilesToMessage(Message $message, array $files, OutputInterface $output, Config $config) {
394
        foreach ($files as $file) {
395
            if (!file_exists($file)) {
396
                $output->writeln('<error>Could not find file to send "'.$file.'". Skipping this file.</error>');
397
                continue;
398
            }
399
400
            $message->addFile(new \SplFileInfo($file), $config->getGitlabUrl(), $config->getGitlabProjectName(), $config->getGitlabJobId());
401
        }
402
    }
403
}
404
405
/*
406
=================ENV IN A PR CONTEXT =========================
407
408
CI_BUILD_TOKEN=xxxxxx
409
HOSTNAME=runner-9431b96d-project-428-concurrent-0
410
PHP_INI_DIR=/usr/local/etc/php
411
PHP_ASC_URL=https://secure.php.net/get/php-7.0.15.tar.xz.asc/from/this/mirror
412
CI_BUILD_BEFORE_SHA=7af13f8e3bd090c7c34750e4badfc66a5f0af110
413
CI_SERVER_VERSION=
414
CI_BUILD_ID=109
415
OLDPWD=/
416
PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2
417
PHP_MD5=dca23412f3e3b3987e582091b751925d
418
CI_PROJECT_ID=428
419
PHPIZE_DEPS=autoconf 		file 		g++ 		gcc 		libc-dev 		make 		pkg-config 		re2c
420
PHP_URL=https://secure.php.net/get/php-7.0.15.tar.xz/from/this/mirror
421
CI_BUILD_REF_NAME=feature/js-ci
422
CI_BUILD_REF=7af13f8e3bd090c7c34750e4badfc66a5f0af110
423
PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie
424
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
425
CI_BUILD_STAGE=test
426
CI_PROJECT_DIR=/builds/tcm-projects/uneo
427
PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2
428
GPG_KEYS=1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3
429
PWD=/builds/tcm-projects/uneo
430
CI_DEBUG_TRACE=false
431
CI_SERVER_NAME=GitLab CI
432
XDEBUG_VERSION=2.5.0
433
GITLAB_CI=true
434
CI_SERVER_REVISION=
435
CI_BUILD_NAME=test:app
436
HOME=/root
437
SHLVL=1
438
PHP_SHA256=300364d57fc4a6176ff7d52d390ee870ab6e30df121026649f8e7e0b9657fe93
439
CI_SERVER=yes
440
CI=true
441
CI_BUILD_REPO=http://gitlab-ci-token:[email protected]/tcm-projects/uneo.git
442
PHP_VERSION=7.0.15
443
444
===================ENV IN A COMMIT CONTEXT
445
446
CI_BUILD_TOKEN=xxxxxx
447
HOSTNAME=runner-9431b96d-project-447-concurrent-0
448
PHP_INI_DIR=/usr/local/etc/php
449
PHP_ASC_URL=https://secure.php.net/get/php-7.0.15.tar.xz.asc/from/this/mirror
450
CI_BUILD_BEFORE_SHA=42dd9686eafc2e8fb0a6b4d2c6785baec229c94a
451
CI_SERVER_VERSION=
452
CI_BUILD_ID=192
453
OLDPWD=/
454
PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2
455
PHP_MD5=dca23412f3e3b3987e582091b751925d
456
CI_PROJECT_ID=447
457
GITLAB_API_TOKEN=xxxxxxxxxxxxxxchangedmanually
458
PHPIZE_DEPS=autoconf 		file 		g++ 		gcc 		libc-dev 		make 		pkg-config 		re2c
459
PHP_URL=https://secure.php.net/get/php-7.0.15.tar.xz/from/this/mirror
460
CI_BUILD_REF_NAME=master
461
CI_BUILD_REF=42dd9686eafc2e8fb0a6b4d2c6785baec229c94a
462
PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie
463
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
464
CI_BUILD_STAGE=test
465
CI_PROJECT_DIR=/builds/dan/washing-test
466
PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2
467
GPG_KEYS=1A4E8B7277C42E53DBA9C7B9BCAA30EA9C0D5763 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3
468
PWD=/builds/dan/washing-test
469
CI_DEBUG_TRACE=false
470
CI_SERVER_NAME=GitLab CI
471
XDEBUG_VERSION=2.5.0
472
GITLAB_CI=true
473
CI_SERVER_REVISION=
474
CI_BUILD_NAME=test
475
HOME=/root
476
SHLVL=1
477
PHP_SHA256=300364d57fc4a6176ff7d52d390ee870ab6e30df121026649f8e7e0b9657fe93
478
CI_SERVER=yes
479
CI=true
480
CI_BUILD_REPO=http://gitlab-ci-token:[email protected]/dan/washing-test.git
481
PHP_VERSION=7.0.15
482
*/
483