From af4fb739e764ff7cda91d71e1b7eb304b28488b5 Mon Sep 17 00:00:00 2001 From: Andreas Stallinger Date: Mon, 21 Aug 2017 18:55:25 +0200 Subject: [PATCH] build: gitlab ci update for new dockerhub account * caching ccache and maven folder on ci * new docker images st4ll1 -> coatisoftware * in build script run setup script if no build/Release folder does not exist --- .gitlab-ci.yml | 157 +++++++++++++++++++++++++++++--------------- script/buildonly.sh | 12 ++++ 2 files changed, 116 insertions(+), 53 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a30b17a..cf7468c9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,50 +1,72 @@ -.script_template: &script_definition + +variables: + MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" + IMAGE_64: coatisoftware/centos6_64_qt_llvm:qt591-llvm401 + IMAGE_32: coatisoftware/centos6_32_qt_llvm:qt591-llvm401 + +## Templates ## + +.build_template: &build_def + stage: build + before_script: + # CCache Config/jobs + - mkdir -p ccache + - export CCACHE_BASEDIR=${PWD} + - export CCACHE_DIR=${PWD}/ccache script: - - ./script/setup.sh - ./script/buildonly.sh all - ./script/buildonly.sh package - ./build/Release/app/Sourcetrail config -z ./setup/license.txt - - cd ./bin/test - - ../../build/Release/test/Sourcetrail_test + - ./script/build.sh r test + artifacts: + name: "$CI_JOB_NAME" + paths: + - Sourcetrail*.tar.gz + expire_in: 3 days -Linux64_test: - image: st4ll1/coati_64 +.deploy_template: &deploy_def + image: alpine stage: deploy + before_script: + - apk add --no-cache lftp git + script: + - VERS=$(git describe --long | sed 's/-/./' | sed 's/-.*//') + - TARGET_DIR=releases-$CI_ENVIRONMENT_NAME/$TYPE/$VERS + - echo $TARGET_DIR/$CI_ENVIRONMENT_NAME/$TYPE/ + - lftp -u $FTP_USER,$FTP_PW -p $FTP_PORT $FTP_ADDR -e "mkdir $TARGET_DIR; mput -O $TARGET_DIR Sourcetrail*; bye" only: - master - - triggers - <<: *script_definition - artifacts: - name: "$CI_JOB_NAME" - paths: - - Sourcetrail*.tar.gz - expire_in: 3 days -Linux64_tag: - image: st4ll1/coati_64 - stage: deploy +## Build Stage ## + +build:Linux64: + image: $IMAGE_64 + cache: + key: cache_linux_64 + paths: + - ccache/ + - java_indexer/.m2/repository + <<: *build_def + +build:Linux32: + image: $IMAGE_32 + cache: + key: cache_linux_32 + paths: + - ccache/ + - java_indexer/.m2/repository + when: manual + <<: *build_def + +build:Linux32_tag: + image: $IMAGE_32 only: - tags - <<: *script_definition - artifacts: - name: "$CI_JOB_NAME$CI_COMMIT_TAG" - paths: - - Sourcetrail*.tar.gz + <<: *build_def -Linux64: - image: st4ll1/coati_64 - stage: deploy - when: manual - <<: *script_definition - artifacts: - name: "$CI_JOB_NAME" - paths: - - Sourcetrail*.tar.gz - expire_in: 3 days - -Linux64_licenseGenerator: - image: st4ll1/coati_64 - stage: deploy +LicenseGenerator: + image: $IMAGE_64 + stage: build when: manual script: - ./script/setup.sh @@ -56,25 +78,54 @@ Linux64_licenseGenerator: - Sourcetrail_license_generator expire_in: 3 days -Linux32: - image: st4ll1/coati_32 - stage: deploy - when: manual - <<: *script_definition - artifacts: - name: "$CI_JOB_NAME" - paths: - - Sourcetrail*.tar.gz - expire_in: 3 days +## Deploy ## -Linux32_tag: - image: st4ll1/coati_32 - stage: deploy +deploy:Linux_staging_beta: + when: manual + environment: + name: staging + variables: + TYPE: beta + <<: *deploy_def + +deploy:Linux_staging_full: + when: manual + environment: + name: staging + variables: + TYPE: full + <<: *deploy_def + +deploy:Linux_production_beta: + when: manual + environment: + name: production + variables: + TYPE: beta + <<: *deploy_def + +deploy:Linux_production_full: + when: manual + environment: + name: production + variables: + TYPE: full + <<: *deploy_def + +deploy:Linux_tag_staging: + environment: + name: staging + variables: + TYPE: beta + <<: *deploy_def only: - tags - <<: *script_definition - artifacts: - name: "$CI_JOB_NAME$CI_COMMIT_TAG" - paths: - - Sourcetrail*.tar.gz + +## could be interesting for daily/weekly/monthly builds +# https://docs.gitlab.com/ce/user/project/pipelines/schedules.html +# +#job:on-schedule: +#only: +# - schedules +# diff --git a/script/buildonly.sh b/script/buildonly.sh index 393f556b..db76ff0b 100755 --- a/script/buildonly.sh +++ b/script/buildonly.sh @@ -6,6 +6,18 @@ MY_PATH=`dirname "$0"` cd $MY_PATH/.. +# run setup script if needed +if [ ! -d "build/Release" ] +then + $MY_PATH/setup.sh + if [ $? -ne 0 ] + then + exit 1; + fi +else + echo "build exists" +fi + # Build target if [ "$1" = "release" ] || [ "$1" = "r" ] || [ "$1" = "" ]