Commit de8aa8ef authored by Rafael's avatar Rafael

Altera arquivo de CI

parent e7d1ab1c
stages:
- build
- delivery
- deploy
- badges
variables:
LC_ALL: 'en_US.UTF-8'
......@@ -69,7 +66,7 @@ variables:
#################################################################################################
# Android APP BUILD #
# WEB APP BUILD #
#################################################################################################
.build_app_cliente_web: &build_app_cliente_web
......@@ -132,221 +129,39 @@ deploy_app_cliente_web:
- rm node_modules
- rm dist
#################################################################################################
# SERVER BUILD #
# BADGES #
#################################################################################################
# .server_build_i: &server_build_i
# generate_badges:
# stage: badges
# tags:
# - rhel7
# - python_script
# when: always
# allow_failure: true
# variables:
# SRV_DIR: srv/src/microcredito/
# DOCKER_REGISTRY: dockerhub.dev.evologica.com.br
# GIT_STRATEGY: fetch
# # cache: {}
# before_script:
# - mkdir public
# script:
# - cd $SRV_DIR
# - chmod +x gradlew
# - ./gradlew spotlessJavaApply
# - ./gradlew assemble
# server_build_test:
# <<: *has_no_tags
# <<: *server_build_i
# stage: fast_test
# server_build:
# <<: *server_build_i
# stage: build
# script:
# - cd $SRV_DIR
# - chmod +x gradlew
# - ./gradlew spotlessJavaApply
# - ./gradlew build
# after_script:
# - mv srv/src/microcredito/configuration/build/libs/configuration-*.jar microcredito.jar
# - python build\generate_badges.py
# artifacts:
# name: srv
# name: pages
# paths:
# - microcredito*.jar
# - ./public/*.svg
# expire_in: 2 weeks
# only:
# - develop
# server_delivery:
# <<: *version
# <<: *has_tag_server
# <<: *server_build_i
# stage: delivery
# pages:
# stage: badges
# script:
# # Seta variaveis
# - JAR_NAME=microcredito-$Version.jar
# - DOCKER_IMAGE_NAME=microcredito:$Version
# - DOCKER_PUSH_TARGET=$DOCKER_REGISTRY/$DOCKER_IMAGE_NAME
# - echo $JAR_NAME
# - echo $DOCKER_IMAGE_NAME
# - echo $DOCKER_PUSH_TARGET
# # Build
# - cd $SRV_DIR
# - chmod +x gradlew
# - ./gradlew spotlessJavaApply
# - ./gradlew build
# - cd ../../..
# - mv srv/src/microcredito/configuration/build/libs/configuration-*.jar $JAR_NAME
# # Gera o dockerfile
# - echo "FROM adoptopenjdk/openjdk8:alpine-jre" > Dockerfile
# - echo "" >> Dockerfile
# - echo "ARG JAR_FILE=$JAR_NAME" >> Dockerfile
# - echo "" >> Dockerfile
# - echo "WORKDIR /opt/app" >> Dockerfile
# - echo "" >> Dockerfile
# - echo "COPY \${JAR_FILE} app.jar" >> Dockerfile
# - echo "" >> Dockerfile
# - echo "ENTRYPOINT [\"java\",\"-jar\",\"app.jar\"]" >> Dockerfile
# # Gera o docker com a imagem
# - docker image build -t $DOCKER_PUSH_TARGET .
# # - docker tag $DOCKER_IMAGE_NAME $DOCKER_PUSH_TARGET
# - docker image push $DOCKER_PUSH_TARGET
# after_script:
# - docker rmi $DOCKER_IMAGE_NAME
# - docker rmi $DOCKER_PUSH_TARGET
# after_script:
# - mv srv/src/microcredito/configuration/build/libs/configuration-*.jar microcredito-$Version.jar
# artifacts:
# name: srv
# paths:
# - microcredito*.jar
server_deploy:
<<: *version
<<: *has_tag_server
stage: deploy
tags:
- rhel7
variables:
GIT_STRATEGY: none
DOCKER_REGISTRY: dockerhub.dev.evologica.com.br
script:
- DOCKER_IMAGE_NAME=$DOCKER_REGISTRY/microcredito:$Version
- echo $DOCKER_IMAGE_NAME
- docker image pull $DOCKER_IMAGE_NAME
- docker stop microcredito
- docker rm microcredito
- docker run -d --name microcredito --expose 8080 -p 8080:8080 --restart unless-stopped $DOCKER_IMAGE_NAME
#################################################################################################
# API #
#################################################################################################
.api_build_i: &api_build_i
variables:
API_SPECS_DIR: srv/src/microcredito/adapters/web/src/main/java/microcredito/adapter/web/specs
API_OUTPUT_DIR: ../../../../../../../../../../../../api_output
ADDITIONAL_PROPERTIES: npmName=@microcredito/client,npmRepository=https://nexus.dev.evologica.com.br/repository/npm-internal,supportsES6=true,typescriptThreePlus=true,legacyDiscriminatorBehavior=false
before_script:
- openapi-generator --version
- json --version
script:
# Compila .yaml
- mkdir api_output
- cd $API_SPECS_DIR
- echo "npx openapi-generator generate -i microcredito.service.yaml -g typescript-fetch --additional-properties npmName=@microcredito/client,npmRepository=https://nexus.dev.evologica.com.br/repository/npm-internal -o $API_OUTPUT_DIR --model-name-suffix ApiModel"
- npx openapi-generator generate -i microcredito.service.yaml -g typescript-fetch --additional-properties npmName=@microcredito/client,npmRepository=https://nexus.dev.evologica.com.br/repository/npm-internal -o $API_OUTPUT_DIR --model-name-suffix ApiModel
# Gera/Altera arquivos do pacote
- cd $API_OUTPUT_DIR
- ls
- echo "init.author.name = admin" > .npmrc
- echo "init.author.email = suporte@evologica.com.br" >> .npmrc
- echo "email=suporte@evologica.com.br" >> .npmrc
- echo "" >> .npmrc
- echo "always-auth=true" >> .npmrc
- echo "_auth=YWRtaW46amo1OFBkMDI=" >> .npmrc
- json -I -f package.json -e "this.files=['dist']"
# - json -I -f package.json -e "this.devDependencies={'typescript':'^3.8.3'}"
# Corrige buggera da exportacao
- echo "import * as AgenteApiModels from './AgenteApi'" > src/apis/index.ts
- echo "import * as ClienteApiModels from './ClienteApi'" >> src/apis/index.ts
- echo "" >> src/apis/index.ts
- echo "import { AgenteApi } from './AgenteApi'" >> src/apis/index.ts
- echo "export { AgenteApi, AgenteApiModels }" >> src/apis/index.ts
- echo "" >> src/apis/index.ts
- echo "import { ClienteApi } from './ClienteApi'" >> src/apis/index.ts
- echo "export { ClienteApi, ClienteApiModels }" >> src/apis/index.ts
- echo "" >> src/apis/index.ts
- echo "export * from './DefaultApi'" >> src/apis/index.ts
- echo "export * from './DominioApi'" >> src/apis/index.ts
- echo "export * from './AnonimoApi'" >> src/apis/index.ts
# Instala e publica novo pacote
- npm i
- ls
- npm run build
- ls
# api_build_test:
# <<: *api_build_i
# stage: fast_test
# tags:
# - android
# when: manual
# allow_failure: true
# - echo "hi"
# artifacts:
# when: on_failure
# name: pages
# paths:
# - api_output
# expire_in: 2 hours
# except:
# - tags
api_build:
<<: *api_build_i
<<: *has_tag_api_internal
stage: build
tags:
- android
artifacts:
when: always
paths:
- api_output
expire_in: 4 hours
api_publish:
<<: *has_tag_api_internal
stage: deploy
tags:
- android
dependencies:
- api_build
script:
- cd api_output
- npm publish
#################################################################################################
# BADGES #
#################################################################################################
generate_badges:
stage: badges
tags:
- python_script
when: always
allow_failure: true
variables:
GIT_STRATEGY: fetch
# cache: {}
before_script:
- mkdir public
script:
- python build\generate_badges.py
artifacts:
name: pages
paths:
- ./public/*.svg
expire_in: 2 weeks
only:
- develop
pages:
stage: badges
script:
- echo "hi"
artifacts:
name: pages
paths:
- public
only:
- master
# - public
# only:
# - master
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment