storageEntry = new HashMap<>();
@@ -252,6 +262,68 @@ private String getPropertySafely(String propertyName) {
}
}
+ /**
+ * Resolves the CI/CD build URL from supported environment variables
+ * (Jenkins, GitLab CI, CircleCI, GitHub Actions, Azure DevOps).
+ *
+ * Returns only valid HTTP/HTTPS URLs.
+ *
+ * @return build URL or {@code null} if unavailable or invalid
+ */
+ private String resolveBuildUrl() {
+ String buildUrl = getEnv(
+ "BUILD_URL", // Jenkins
+ "CI_JOB_URL", // GitLab
+ "CIRCLE_BUILD_URL" // CircleCI
+ );
+
+ // GitHub Actions
+ if (buildUrl == null && System.getenv("GITHUB_RUN_ID") != null) {
+ String server = System.getenv("GITHUB_SERVER_URL");
+ String repo = System.getenv("GITHUB_REPOSITORY");
+ String runId = System.getenv("GITHUB_RUN_ID");
+
+ if (server != null && repo != null && runId != null) {
+ buildUrl = String.format("%s/%s/actions/runs/%s", server, repo, runId);
+ }
+ }
+
+ // Azure DevOps
+ if (buildUrl == null && System.getenv("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI") != null) {
+ String collection = System.getenv("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI");
+ String project = System.getenv("SYSTEM_TEAMPROJECT");
+ String buildId = System.getenv("BUILD_BUILDID");
+
+ if (collection != null && project != null && buildId != null) {
+ buildUrl = String.format("%s/%s/_build/results?buildId=%s", collection, project, buildId);
+ }
+ }
+
+ if (buildUrl != null && !(buildUrl.startsWith("http://") || buildUrl.startsWith("https://"))) {
+ return null;
+ }
+
+ try {
+ if (buildUrl != null) {
+ new java.net.URI(buildUrl);
+ }
+ } catch (Exception e) {
+ return null;
+ }
+
+ return buildUrl;
+ }
+
+ private String getEnv(String... keys) {
+ for (String key : keys) {
+ String value = System.getenv(key);
+ if (value != null && !value.isEmpty()) {
+ return value;
+ }
+ }
+ return null;
+ }
+
private boolean getCreateParam() {
try {
return provider.getProperty(CREATE_TEST_PROPERTY_NAME).equalsIgnoreCase(TRUE);
@@ -290,13 +362,30 @@ private void addMeta(Map body, String rid) {
}
}
- private void addLinks(Map body, String rid) {
- body.put("links", new ArrayList<>());
- List