62 lines
2.7 KiB
YAML
Raw Permalink Normal View History

2021-11-26 13:50:02 +01:00
include:
- project: "SharedLibraries/CommonCI/webservices-common-ci"
2021-11-29 17:15:53 +01:00
ref: 4.x
2021-11-26 13:50:02 +01:00
file: "webservices-gitlab-ci-template-dotnetcore.yml"
2021-11-26 14:00:42 +01:00
versionize:
before_script:
- VERSION=`echo -e "import yaml\nwith open('openapi.yaml') as f:d=yaml.load(f)\nprint d['info']['version']" | python`
2021-11-26 14:03:08 +01:00
2021-12-07 12:53:31 +01:00
extract_client_definition:
after_script:
2021-12-07 13:20:30 +01:00
- URL="/"
2021-12-07 13:35:42 +01:00
- if [[ "$CI_COMMIT_BRANCH" =~ ^test_deployment_v[[:digit:]] ]]; then URL="https://test.webservices.krohne.com/"; fi
- if [[ "$CI_COMMIT_BRANCH" =~ ^development_deployment_v[[:digit:]] ]]; then URL="https://dev.webservices.krohne.com/"; fi
- if [[ "$CI_COMMIT_BRANCH" =~ ^production_deployment_v[[:digit:]] ]]; then URL="https://prod.webservices.krohne.com/"; fi
2021-12-07 13:15:07 +01:00
- cat ws.json | jq 'setpath(["servers", 0, "url"]; "'$URL'")' > ws.json-new
- rm ws.json && mv ws.json-new ws.json
2021-12-07 12:53:31 +01:00
2021-11-29 18:01:30 +01:00
.deploy_test_dev:
extends: .deploy
tags:
- test-deployment-de01rdtst01
2021-11-26 14:54:40 +01:00
.deploy:
stage: deploy
image: devnexus.krohne.com:18079/repository/docker-krohne/krohnedockerbash:1.1.0
except:
- tags
artifacts:
paths:
- instance.txt
- api_major_version.txt
- api_version.txt
expire_in: 1 day
needs:
- dockerize
when: manual
allow_failure: false
2021-11-26 15:13:51 +01:00
variables:
WEBSERVICE_PORT: 8080
2021-11-26 15:03:15 +01:00
before_script:
2021-11-26 15:05:41 +01:00
- PKG_VERSION=$(echo -e "import yaml\nwith open('openapi.yaml') as f:d=yaml.load(f)\nprint(d['info']['version'])" | python)
2021-11-26 15:03:15 +01:00
- REFCNT=$(git rev-list --count ${CI_COMMIT_SHA})
- VERSION=${PKG_VERSION}.${REFCNT}.${CI_COMMIT_REF_NAME}
2021-11-26 16:59:09 +01:00
- API_VERSION=$PKG_VERSION
- API_MAJOR_VERSION=`echo $PKG_VERSION | awk -F. '{print $1}'`
2021-11-26 14:54:40 +01:00
script:
- echo $INSTANCE_SPECIFIER > instance.txt
- echo -n $API_VERSION > api_version.txt
- echo -n $API_MAJOR_VERSION > api_major_version.txt
- CONTAINER_NAME="${CI_PROJECT_PATH_SLUG}-${INSTANCE_SPECIFIER}-${API_MAJOR_VERSION}"
2021-12-06 17:53:31 +01:00
- SERVICE_VOLUME="${CONTAINER_NAME}-data"
2021-11-26 14:54:40 +01:00
- SERVICE_PORT=$((SERVICE_FIRST_PORT + SERVICE_PORT_OFFSET + (API_MAJOR_VERSION - 1) % 5))
- echo "Service port is ${SERVICE_PORT}"
2021-12-06 17:53:31 +01:00
- docker volume inspect $SERVICE_VOLUME || docker volume create $SERVICE_VOLUME
2021-11-26 14:54:40 +01:00
- docker stop $CONTAINER_NAME || echo "$CONTAINER_NAME not running, anyway okay"
- docker pull $IMAGE_NAME:$VERSION
2021-12-06 18:05:49 +01:00
- echo "docker run -d --rm -e TZ=Europe/Berlin -p $SERVICE_PORT:$WEBSERVICE_PORT --name $CONTAINER_NAME -v $SERVICE_VOLUME:/opt/service/config -e WEBSERVICE_INSTANCE=$INSTANCE_SPECIFIER $IMAGE_NAME:$VERSION" > /start-scripts/${CONTAINER_NAME}.sh
2021-11-26 14:54:40 +01:00
- chmod 755 /start-scripts/${CONTAINER_NAME}.sh
2021-11-26 14:57:26 +01:00
- /start-scripts/${CONTAINER_NAME}.sh