-
Notifications
You must be signed in to change notification settings - Fork 3
/
create_label-vmx-winserver2019-vs2019-ci.sh
executable file
·59 lines (50 loc) · 2.37 KB
/
create_label-vmx-winserver2019-vs2019-ci.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh -e
# Copyright 2021 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
# This example script allows to see the existing Label and create a new version of it
# Please check the images URLs in Label definitions below
#
token=$1
[ "$token" ] || exit 1
hostport=$2
[ "$hostport" ] || hostport=localhost:8001
label=winserver2019-vs2019_vmx
# It's a bit dirty, but works for now - probably better to create API call to find the latest label
curr_label=$(curl -s -u "admin:$token" -k "https://$hostport/api/v1/label/?filter=name=\"$label\"" | sed 's/},{/},\n{/g' | tail -1)
curr_version="$(echo "$curr_label" | grep -o '"version": *[0-9]\+' | tr -dc '0-9')"
echo "Current label '$label:$curr_version': $curr_label"
[ "x$curr_version" != "x" ] || curr_version=0
new_version=$(($curr_version+1))
echo
echo "Create the new version of Label '$label:$new_version' ?"
echo "Press any key to create or Ctrl-C to abort"
read w1
label_id=$(curl -s -u "admin:$token" -k -X POST -H 'Content-Type: application/yaml' -d '---
name: "'$label'"
version: '$new_version'
definitions:
- driver: vmx
options:
images: # For test purposes images are used as symlink to aquarium-bait/out so does not need checksum
- url: https://artifact-storage/aquarium/image/vmx/winserver2019-VERSION/winserver2019-VERSION.tar.xz
- url: https://artifact-storage/aquarium/image/vmx/winserver2019-vs2019-VERSION/winserver2019-vs2019-VERSION.tar.xz
- url: https://artifact-storage/aquarium/image/vmx/winserver2019-vs2019-ci-VERSION/winserver2019-vs2019-ci-VERSION.tar.xz
resources:
cpu: 14
ram: 12
disks:
vs2019:
type: exfat
size: 10
reuse: true
metadata:
JENKINS_AGENT_WORKSPACE: D:\
' "https://$hostport/api/v1/label/" | grep -o '"UID": *"[^"]\+"' | cut -d':' -f 2 | tr -d ' "')
echo "Created Label ID: ${label_id}"