Browse Source

Use artifact name rather than log_url

So that we can return the preview URL as the success url, use the
artifact name to look up the forward URL.

Change-Id: I8d67e1527d8f911579779a9a036a3c7f5c79a27f
changes/09/640509/2
James E. Blair 2 months ago
parent
commit
f5121119c8
1 changed files with 11 additions and 5 deletions
  1. 11
    5
      zuul-preview/main.cc

+ 11
- 5
zuul-preview/main.cc View File

@@ -122,7 +122,7 @@ int main(int, char**)
122 122
   // (protected by an internal mutex) and expect exactly one line of
123 123
   // output for each.
124 124
   // Expected input:
125
-  // https://zuul.opendev.org site.926bb0aaddad4bc3853269451e115dcb.openstack.preview.opendev.org
125
+  // https://zuul.opendev.org site.167715b656ee4504baa940c5bd9f3821.openstack.preview.opendev.org
126 126
   while (getline(cin, input)) {
127 127
 
128 128
     // Split the input into api_url, hostname
@@ -163,12 +163,18 @@ int main(int, char**)
163 163
         web::http::methods::GET, uri.to_string()).get();
164 164
       // body is a web::json::value
165 165
       auto body = response.extract_json().get();
166
+      auto artifacts = body["artifacts"].as_array();
166 167
 
167
-      // TODO: use artifact instead of log_url
168
-      // body["log_url"].as_string() returns a const std::string&
169
-      cout << body["log_url"].as_string() << endl;
168
+      string artifact_url = "Artifact_not_found";
169
+      for (uint i = 0; i < artifacts.size(); i++) {
170
+        if (artifacts[i]["name"].as_string() == artifact) {
171
+          artifact_url = artifacts[i]["url"].as_string();
172
+        }
173
+      }
170 174
 
171
-      cache.put(hostname, body["log_url"].as_string());
175
+      cout << artifact_url << endl;
176
+
177
+      cache.put(hostname, artifact_url);
172 178
     } catch (...) {
173 179
       // If anything goes wrong, we still need to return only a single
174 180
       // string to apache, and recover for the next request, so we

Loading…
Cancel
Save