|
1 | 1 | package io.cucumber.core.runtime;
|
2 | 2 |
|
| 3 | +import io.cucumber.cienvironment.CiEnvironment; |
3 | 4 | import io.cucumber.core.eventbus.EventBus;
|
4 | 5 | import io.cucumber.core.gherkin.Feature;
|
5 | 6 | import io.cucumber.core.logging.Logger;
|
6 | 7 | import io.cucumber.core.logging.LoggerFactory;
|
7 | 8 | import io.cucumber.core.runner.Runner;
|
| 9 | +import io.cucumber.messages.ProtocolVersion; |
| 10 | +import io.cucumber.messages.types.Ci; |
8 | 11 | import io.cucumber.messages.types.Envelope;
|
| 12 | +import io.cucumber.messages.types.Git; |
| 13 | +import io.cucumber.messages.types.Meta; |
| 14 | +import io.cucumber.messages.types.Product; |
9 | 15 | import io.cucumber.plugin.event.Result;
|
10 | 16 | import io.cucumber.plugin.event.Status;
|
11 | 17 | import io.cucumber.plugin.event.TestRunFinished;
|
|
18 | 24 | import java.util.ResourceBundle;
|
19 | 25 | import java.util.function.Consumer;
|
20 | 26 |
|
| 27 | +import static io.cucumber.cienvironment.DetectCiEnvironment.detectCiEnvironment; |
21 | 28 | import static io.cucumber.core.exception.ExceptionUtils.printStackTrace;
|
22 |
| -import static io.cucumber.createmeta.CreateMeta.createMeta; |
23 | 29 | import static io.cucumber.messages.TimeConversion.javaInstantToTimestamp;
|
24 | 30 | import static java.util.Collections.singletonList;
|
25 | 31 |
|
@@ -48,10 +54,38 @@ public void startTestRun() {
|
48 | 54 |
|
49 | 55 | private void emitMeta() {
|
50 | 56 | Envelope envelope = new Envelope();
|
51 |
| - envelope.setMeta(createMeta("cucumber-jvm", VERSION, System.getenv())); |
| 57 | + envelope.setMeta(createMeta()); |
52 | 58 | bus.send(envelope);
|
53 | 59 | }
|
54 | 60 |
|
| 61 | + private Meta createMeta() { |
| 62 | + return new Meta( |
| 63 | + ProtocolVersion.getVersion(), |
| 64 | + new Product("cucumber-jvm", VERSION), |
| 65 | + new Product(System.getProperty("java.vm.name"), System.getProperty("java.vm.version")), |
| 66 | + new Product(System.getProperty("os.name"), null), |
| 67 | + new Product(System.getProperty("os.arch"), null), |
| 68 | + createCi()); |
| 69 | + } |
| 70 | + |
| 71 | + private Ci createCi() { |
| 72 | + CiEnvironment ciEnvironment = detectCiEnvironment(System.getenv()); |
| 73 | + if (ciEnvironment == null) { |
| 74 | + return null; |
| 75 | + } |
| 76 | + |
| 77 | + CiEnvironment.Git git = ciEnvironment.getGit(); |
| 78 | + return new Ci( |
| 79 | + ciEnvironment.getName(), |
| 80 | + ciEnvironment.getUrl(), |
| 81 | + ciEnvironment.getBuildNumber(), |
| 82 | + new Git( |
| 83 | + git.getRemote(), |
| 84 | + git.getRevision(), |
| 85 | + git.getBranch(), |
| 86 | + git.getTag())); |
| 87 | + } |
| 88 | + |
55 | 89 | private void emitTestRunStarted() {
|
56 | 90 | log.debug(() -> "Sending run test started event");
|
57 | 91 | start = bus.getInstant();
|
|
0 commit comments