This commit is contained in:
jalr 2018-02-12 23:23:53 +01:00
parent 8b1b45c3b2
commit b69699e56f

View file

@ -1,48 +1,64 @@
before_script:
- PACKER_VERSION=1.2.0
- PACKER_SHA256SUM=d1b0fcc4e66dfe4919c25752d028a4e4466921bf0e3f75be3bbf1c85082e8040
- ANSIBLE_VERSION=2.4.3.0
- ANSIBLE_SHA256SUM=0e98b3a56928d03979d5f8e7ae5d8e326939111b298729b03f00b3ad8f998a3d
image: docker:latest
- wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip
- wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_SHA256SUMS
- wget https://releases.ansible.com/ansible/ansible-${ANSIBLE_VERSION}.tar.gz
- mkdir bin
- sed -i '/.*linux_amd64.zip/!d' packer_${PACKER_VERSION}_SHA256SUMS
- sha256sum --check --strict packer_${PACKER_VERSION}_SHA256SUMS
- unzip packer_${PACKER_VERSION}_linux_amd64.zip -d bin
- rm -f packer_${PACKER_VERSION}_linux_amd64.zip
- echo ${ANSIBLE_SHA256SUM} ansible-${ANSIBLE_VERSION}.tar.gz|sha256sum --check --strict
- tar xvf ansible-${ANSIBLE_VERSION}.tar.gz
- rm -f ansible-${ANSIBLE_VERSION}.tar.gz
- PATH="$PATH:$PWD/bin:$PWD/ansible-${ANSIBLE_VERSION}/bin"
variables:
PACKER_VERSION: 1.2.0
stages:
- test
- build
- setup
- rootfs
- torrent
test:
stage: test
prepare:
variables:
ZIPFILE: packer_${PACKER_VERSION}_linux_amd64.zip
stage: setup
cache:
key: binaries
paths:
- bin
script:
- ansible-playbook
- packer validate packer.json
tags:
- shell
- x86
build:
stage: build
script:
- packer build packer.json
- mkdir -p bin
- |
[ ! -e bin/packer ] && wget -c https://releases.hashicorp.com/packer/${PACKER_VERSION}/${ZIPFILE} && unzip "$ZIPFILE" -d bin && rm -f "$ZIPFILE"
- apk add --no-cache mktorrent
only:
- master
- /ci/
packer:
stage: rootfs
script:
- bin/packer build packer.json
- gzip -k -f rootfs.tar
artifacts:
paths:
- rootfs.tar
tags:
- shell
- x86
- rootfs.tar
expire_in: 2 weeks
cache:
key: binaries
paths:
- bin
policy: pull
only:
- /ci/
mktorrent:
stage: torrent
dependencies:
- packer
variables:
ANNOUNCE: udp://tracker.sbruder.de:6969/announce
WEBSEED: http://10.2.2.1:8081/rootfs.tar.gz
script:
- mktorrent -a "$ANNOUNCE" -o rootfs.torrent -l 22 -w "$WEBSEED" rootfs.tar.gz
artifacts:
paths:
- rootfs.torrent
expire_in: 2 weeks
cache:
key: binaries
paths:
- bin
policy: pull
only:
- /ci/