-
Notifications
You must be signed in to change notification settings - Fork 0
/
packer-build.cmd
60 lines (46 loc) · 1.17 KB
/
packer-build.cmd
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
60
@echo off
rem build or rebuild virtualbox
rem set version
set /p version=<version
rem get latest tag
for /f "delims=" %%A in ('git describe') do set "latesttag=%%A"
rem check tag
if "%version%" == "%latesttag%" goto tagexists
rem stop and create virtualbox
vagrant halt
if errorlevel 1 goto error
rem commit changes
git add --all
if errorlevel 1 goto error
git commit -m "vagrant-ubuntu-14.04-bind9 %version%"
git push
if errorlevel 1 goto error
git tag -a %version% -m "vagrant-ubuntu-14.04-bind9 %version%"
if errorlevel 1 goto error
git push --tags
if errorlevel 1 goto error
rem export virtualbox vm
del *.ova
del *.box
vboxmanage export vagrant-ubuntu-14-04-bind9 -o vagrant-ubuntu-14.04-bind9-%version%.ova
if errorlevel 1 goto error
rem create & push vagrant box
:retry
packer build -force -var 'version=%version%' -var 'token=%ATLAS_TOKEN%' packer-vagrant-ubuntu-14.04-bind9.json
if errorlevel 1 goto retry
rem cleanup
del *.ova
del *.box
rmdir packer_cache /s /q
echo "vagrant build successful"
goto end
:error
echo "vagrant build not successful"
goto end
:success
echo "vagrant build successful"
goto end
:tagexists
echo "version %version%" already exists"
goto end
:end