Vasyl Saienko | 224e318 | 2018-12-11 10:38:24 +0200 | [diff] [blame] | 1 | package com.mirantis.mk |
| 2 | |
| 3 | /** |
| 4 | * |
| 5 | * Functions to work with mirror.mirantis.com |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * Returns latest meta for latest available snapshot |
| 11 | * |
| 12 | * @param host mirror host |
| 13 | * @param version version of components (nightly|testing|stable|release-x) |
| 14 | * @param component component name (salt-formulas) |
| 15 | * @param distribution ubuntu distribution to get repo for (xenial by default) |
| 16 | */ |
| 17 | def getLatestSnapshotMeta(host, version, component, distribution='xenial') { |
| 18 | common = new com.mirantis.mk.Common() |
| 19 | |
| 20 | def repoUrl = "http://${host}/${version}/${component}/${distribution}.target.txt" |
| 21 | def res |
| 22 | def snapshotName |
| 23 | def meta = [:] |
| 24 | |
| 25 | res = common.shCmdStatus("curl ${repoUrl}") |
| 26 | // Return multiple lines where first one is the latest snapshot |
| 27 | // ../../.snapshots/nightly-salt-formulas-xenial-2018-12-10-204157 |
| 28 | snapshotName = res['stdout'].split("\n")[0].tokenize('/').last().trim() |
| 29 | |
| 30 | meta['repoUrl'] = "http://${host}/.snapshots/${snapshotName}" |
| 31 | meta['repoName'] = snapshotName |
| 32 | |
| 33 | return meta |
| 34 | } |