Commit 081b081c authored by Giacomo Bernini's avatar Giacomo Bernini
Browse files

Added ci/cd jenkins and docker files

parent ad4e522c
Loading
Loading
Loading
Loading

.jenkins.sh

0 → 100644
+19 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright ETSI 2017
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt

cd "$(dirname "$0")"

run_dir="$(pwd)"

rm build/*-API.yaml
rm build/*-API.json

cd docker

./build-container.sh

./run-container.sh "${run_dir}"
OUTCOME=$?

exit $OUTCOME

docker/Dockerfile

0 → 100644
+33 −0
Original line number Diff line number Diff line
# Copyright ETSI 2017
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt

FROM alpine:3.10.0

RUN env
RUN apk update
RUN apk add bash
RUN apk add nodejs
RUN apk add nodejs-npm
RUN apk add asciidoctor
RUN apk add openjdk8
RUN apk add ca-certificates wget && update-ca-certificates 
RUN apk add openssl
RUN gem install rdoc --pre || gem install rdoc --pre
RUN gem install asciidoctor-pdf-cjk
RUN wget https://forge.etsi.org/swagger2markup-cli-1.3.2.jar
RUN npm config set proxy $http_proxy
RUN npm install -g swagger-cli
RUN npm install -g json-refs
RUN npm install -g yamljs

ADD validate-in-docker.sh /validate-in-docker.sh
RUN chmod +x /validate-in-docker.sh

ADD swg2mrkup /bin/swg2mrkup
RUN chmod +x /bin/swg2mrkup

ADD oas2pdf /bin/oas2pdf
RUN chmod +x /bin/oas2pdf

ENTRYPOINT ["/validate-in-docker.sh"]
+25 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright ETSI 2017
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt

#set -x

proxy = ""
if [[ ! -v http_proxy ]]; then
    echo "http_proxy is not set"
elif [[ -z "$http_proxy" ]]; then
    echo "http_proxy is empty"
else
    echo "http_proxy is set to $http_proxy"
    if [[ $http_proxy =~ ^http:\/\/[0-9] ]]; then
        echo "starts with http"
        proxy=$http_proxy
    elif [[ $http_proxy =~ ^[0-9] ]]; then
        echo "starts with number"
        proxy=http://$http_proxy
    fi
fi

echo "Proxy set to $proxy"

docker build --build-arg http_proxy=$proxy --build-arg https_proxy=$proxy -t openapivalidator .
 No newline at end of file

docker/oas2pdf

0 → 100644
+61 −0
Original line number Diff line number Diff line
#!/bin/bash
#Copyright (c) ETSI 2017.

# This software is subject to copyrights owned by ETSI. Non-exclusive permission 
# is hereby granted, free of charge, to copy, reproduce and amend this file 
# under the following conditions: It is provided "as is", without warranty of any 
# kind, expressed or implied. 

# ETSI shall never be liable for any claim, damages, or other liability arising 
# from its use or inability of use.This permission does not apply to any documentation 
# associated with this file for which ETSI keeps all rights reserved. The present 
# copyright notice shall be included in all copies of whole or part of this 
# software and shall not imply any sub-license right.
#
# Author: michele.carignani@etsi.org
#
# This script takes an OpenAPI file in input and creates
# a PDF file with the content.
#
# Prerequisites: 
#  - https://github.com/Swagger2Markup/swagger2markup-cli
#  - Asciidoctor (sudo apt-get install asciidoctor)
#  - Asciidoctor-pdf (sudo gem install asciidoctor-pdf)
#
# Usage:
#    oas2pdf <oasfile> (e.g. myapi.json)
#
# Result:
#    A new pdf file is created in the working directory (e.g. myapi.pdf)
#
#
#
#

# Configuration

# Change this if needed
SWG2MRKUP=swg2mrkup
ASCIIDOCPDF=asciidoctor-pdf

# Setup
WD=$(pwd)
TWD=$(mktemp -d)

INFILE=$(basename ${1?"Error: missing input file name"} )
OUTFILE="${INFILE%.*}"

echo "$INFILE, $OUTFILE"

echo "Converting to asciidoc.."
${SWG2MRKUP} convert -i "$1" -f "$TWD/$OUTFILE"
echo

echo "Converting to PDF.."
"${ASCIIDOCPDF}" "$TWD/${OUTFILE}.adoc" -o "$WD/${OUTFILE}.pdf"
echo

echo "Done."
# Clean up
rm -r $TWD
+27 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright ETSI 2017
# See: https://forge.etsi.org/etsi-forge-copyright-statement.txt

# Change this variable to true if you want
# to copy the created yaml files to a web served directory
#
#
WEB_PUBLISH=true

f="${1:-`pwd`}"
filter="$2"

echo "Mounting dir $f as /work"

if [ -n "$JOB_BASE_NAME" -a "$WEB_PUBLISH" = true ] ; then 
  s="/var/www/html/api/nfv/$JOB_BASE_NAME/$BUILD_NUMBER"
  mkdir -v -p "$s"
  echo "Mounting dir $s as /storage"  
  docker run -v "$f":/work -v "$s":/storage openapivalidator "/work" "/storage" "$filter"
else
  docker run -v "$f":/work openapivalidator "/work" "/storage" "$filter"
fi 



Loading