Skip to content

Instantly share code, notes, and snippets.

@doevelopper
Created December 7, 2018 16:44
Show Gist options
  • Save doevelopper/98ae0d2230492dfb7230704bcae7392a to your computer and use it in GitHub Desktop.
Save doevelopper/98ae0d2230492dfb7230704bcae7392a to your computer and use it in GitHub Desktop.
#Read https://rolln.de/knoppo/xtract/blob/master/.gitlab-ci.yml
stages:
- configure
- compile
- unit-testing
- package
- integration-testing
- verify
- code-review
- install
- site
- deploy
- clean
variables:
GIT_DEPTH: "1"
# GIT_SUBMODULE_STRATEGY: "none"
# GET_SOURCES_ATTEMPTS: "3"
# ARTIFACT_DOWNLOAD_ATTEMPTS: "2"
# GIT_SUBMODULE_STRATEGY: "recursive"
# GIT_STRATEGY: "fetch"
# GIT_CHECKOUT: "false"
DOCKER_REGISTRY_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
DOCKER_REGISTRY_IMAGE_LATEST_TAG: $CI_REGISTRY_IMAGE:latest
SONAR_URL: "https://latest-fiasco.acme"
CACHE_DIR: "${PWD}/.cache"
BUILD_DIRECTORY: "build-target-$CI_PROJECT_NAME"
BUILD_GENERATOR: "Unix Makefiles"
COVERITY_COVERAGE_FLAG: "--all --enable-slow"
LSB_RELEASE_ID: "$(lsb_release -i 2> /dev/null || echo Distributor ID: Unknown)"
LSB_RELEASE_RELEASE: "$(lsb_release -r 2> /dev/null || echo Release: Unknown)"
before_script:
- date
- echo "Running $CI_JOB_NAME in stage $CI_JOB_STAGE"
- echo "Version ${CI_BUILD_REF} / ${CI_BUILD_REF_NAME}"
- export NUM_CORES=$(nproc --all)
- gcc --version
- g++ --version
- cmake --version
- doxygen --version
- uncrustify --version
- export CCACHE_BASEDIR=$CI_PROJECT_DIR
- export OS_NAME=$(lsb_release -is)
- export OS_VERS_LONG=$(lsb_release -rs | sed -r "s/^([0-9]+).*/\1/") || true
- export PROJECT_NAME=$CI_PROJECT_NAME
- export TAG=$CI_BUILD_REF_NAM
- export BUILD_DATE=$(date +%Y-%m-%d-%H:%M:%S)
- export VERSION=`git describe --first-parent`
- echo "Version ${CI_BUILD_REF} / ${CI_BUILD_REF_NAME}"
- export PATH=/opt/dds/bin:${PATH}
- export LD_LIBRARY_PATH=/opt/dds/lib:${LD_LIBRARY_PATH}
- export CMAKE_PREFIX_PATH=/opt/Qt5.11.2/5.11.2/gcc_64:$CMAKE_PREFIX_PATH
- export GIT_SSL_NO_VERIFY=1
after_script:
- date
.aarch32-target-build-template: &aarch32
before_script:
- export PATH=/opt/arm-linux-gnueabihf/bin/:$PATH
- export TRIPLET=arm-linux-gnueabihf
.armv8l-build-template: &armv8l
before_script:
- export PATH=/opt/armv8l-linux-gnueabihf/bin/:$PATH
- export TRIPLET=armv8l-linux-gnueabihf
.aarch64-build-template: &aarch64
before_script:
- export PATH=/opt/aarch64-linux-gnu/bin/:$PATH
- export TRIPLET=aarch64-linux-gnu
.vxworks-build-template: &itli386
variable:
- PFX : "cc"
before_script:
- export PATH=/${WIND_BASE}/:/${WIND_BASE}/bin/:$PATH
- export TRIPLET={PFX}-pentim
.build_template: &build_definition
script:
- $CXX --version
- export CCACHE_BASEDIR=$CI_PROJECT_DIR
.benchmark_template: &benchmark_definition
script:
- $CXX --version
- cmake --version
- ccache --version
only:
variables:
- $ENABLE_BENCHMARKS
tags:
- benchmark
artifacts:
paths:
- $CI_PROJECT_DIR/build/benchmark.txt
.variables: &build_debug_variables
CMAKE_BUILD_TYPE: "Debug"
.variables: &build_release_variables
CMAKE_BUILD_TYPE: "Release"
.variables: &build_coverage_variables
CMAKE_BUILD_TYPE: "Coverage"
.variables: &build_profiling_variables
CMAKE_BUILD_TYPE: "Profiling"
.agent-who: &agent-who
retry: 1
tags:
# - dev-platform
# - dds
- dds-ci
.variables: &cross-compile
CC: ${TRIPLET}-gcc
CXX: ${TRIPLET}-g++
NM: ${TRIPLET}-nm
AR: ${TRIPLET}-ar
AS: ${TRIPLET}-as
LD: ${TRIPLET}-ld
CPP: ${TRIPLET}-cpp
OBJDUMP: ${TRIPLET}-objdump
OBJCOPY: ${TRIPLET}-objcopy
READELF: ${TRIPLET}-readelf
RANLIB: ${TRIPLET}-ranlib
GDB: ${TRIPLET}-gdb
GFORTRAN: ${TRIPLET}-gfortran
STRINGS: ${TRIPLET}-strings
SIZE: ${TRIPLET}-size
GCOV: ${TRIPLET}-gcov
STRIP: ${TRIPLET}-strip
GPROF: ${TRIPLET}-gprof
.default-cache: &default-cache
key: "3rt_party_lib"
paths:
- $BUILD_DIRECTORY
.push-cache: &push-cache
cache:
<<: *default-cache
policy: push
.pull-cache: &pull-cache
cache:
<<: *default-cache
policy: pull
.docker: &docker
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay
DOCKER_HOST: tcp://docker:2375
tags:
- docker
.only_stable: &only_stable
only:
- master
- /^release-.*$/
.tumbleweed: &tumbleweed
only:
- develop
- /^feature-.*$/
- /^hotfix-.*$/
- /^bugfix-.*$/
- /^support-.*$/
- /^poc-.*$/
.branch_exceptions: &branch_exceptions
only:
- branches
except:
- coverity_scan
.only_stable: &only_stable
only:
- master
- /^release-.*$/
.only-canonical-masters: &only-canonical-masters
only:
- master@gitlab-org/doevlopper/cppbdd101
.prerequisites: &prerequisites
before_script:
- echo "Building $CI_BUILD_NAME"
- uname -a
.except-docs: &except-docs
except:
- /(^docs[\/-].*|.*-docs$)/
.except-qa: &except-qa
except:
- /(^qa[\/-].*|.*-qa$)/
.except-docs-and-qa: &except-docs-and-qa
except:
- /(^docs[\/-].*|.*-docs$)/
- /(^qa[\/-].*|.*-qa$)/
.setupt-dev-tools: &setupt-dev-tools
script:
- echo "shudl install gtest gbenchmark..."
artifacts:
when: on_failure
expire_in: 31d
paths:
- log/development.log
.single-script-job: &single-script-job
# image: ruby:2.4-alpine
stage: unit-testing
cache: {}
dependencies: []
variables: &single-script-job-variables
GIT_STRATEGY: none
before_script:
- echo "blqblq"
# Review docs base
.review-docs: &review-docs
<<: *agent-who
<<: *single-script-job
variables:
<<: *single-script-job-variables
environment:
name: review-docs/$CI_COMMIT_REF_SLUG
url: http://$CI_ENVIRONMENT_SLUG.$DOCS_REVIEW_APPS_DOMAIN/$DOCS_GITLAB_REPO_SUFFIX
on_stop: review-docs-cleanup
review-docs-deploy-manual:
<<: *review-docs
stage: site
script:
- echo "To preview the docs changes live"
when: manual
only:
- branches@gitlab-org/doevlopper/cppbdd101
<<: *except-docs-and-qa
review-docs-deploy:
<<: *review-docs
stage: deploy
script:
- echo ""
only:
- /(^docs[\/-].*|.*-docs$)/@gitlab-org/doevlopper/cppbdd101
- /(^docs[\/-].*|.*-docs$)/@gitlab-org/doevlopper/cppbdd101
<<: *except-qa
review-docs-cleanup:
<<: *review-docs
stage: clean
environment:
name: review-docs/$CI_COMMIT_REF_SLUG
action: stop
script:
- echo "Cleanup remote environment of docs"
when: manual
only:
- branches@gitlab-org/doevlopper/cppbdd101
review:
stage: code-review
allow_failure: true
before_script:
- echo "Code Review"
variables:
GIT_DEPTH: "1"
HOST_SUFFIX: "$CI_ENVIRONMENT_SLUG"
DOMAIN: "-$CI_ENVIRONMENT_SLUG.$REVIEW_APPS_DOMAIN"
GITLAB_HELM_CHART_REF: "master"
when: manual
script:
- echo "Review environment for review/$CI_COMMIT_REF_NAME"
- echo "Sent for review"
#- curl -u "$GF_API_KEY":"$GF_API_SECRET" "${GF_DEPLOY_URL}?sha=${CI_COMMIT_SHA}&ref=${CI_COMMIT_REF_SLUG}&org=${GF_TARGET_ORG_NAME}&env=${GF_TARGET_ENV_UUID}&api=${GF_TARGET_API_UUID}&dockerImg=${CI_REGISTRY_IMAGE}&name=${GITLAB_PROJECT_NAME}&projId=${GITLAB_PROJECT_ID}&port=${APP_SERVICE_PORT}"
environment:
name: review/$CI_COMMIT_REF_NAME
# url: https://gitlab-$CI_ENVIRONMENT_SLUG.$REVIEW_APPS_DOMAIN
url: https://gitlab.org/$CI_PROJECT_PATH/-/jobs/$CI_JOB_ID/artifacts/raw/$BUILD_DIRECTORY/x86_64-Linux-GNU_GCC_
on_stop: stop_review
only:
refs:
- branches@gitlab-org/doevlopper/cppbdd101
except:
refs:
- master
- /feature\/.+/
- /(^docs[\/-].*|.*-docs$)/
- /^[Ww][Ii][Pp]-.*$/
stop_review:
<<: *single-script-job
stage: code-review
allow_failure: true
when: manual
cache: {}
dependencies: []
before_script: []
script:
- echo "Stop reviewi ($CI_JOB_NAME in $CI_JOB_STAGE)"
# - curl -u "$GF_API_KEY":"$GF_API_SECRET" "${GF_DEPLOY_URL}?entryPoint=stop&ref=${CI_COMMIT_REF_SLUG}&org=${GF_TARGET_ORG_NAME}&env=${GF_TARGET_ENV_UUID}&name=${GITLAB_PROJECT_NAME}&projId=${GITLAB_PROJECT_ID}"
after_script:
- echo "Review stopped"
environment:
name: review/$CI_COMMIT_REF_NAME
action: stop
only:
refs:
- branches@gitlab-org/doevlopper/cppbdd101
except:
refs:
- master
- /(^docs[\/-].*|.*-docs$)/
# except:
# - master
# - tags
# only:
# - branches
#linux_build_x86_64:
# <<: *build_definition
# variables:
# <<: *build_release_variables
# only:
# variables:
# - $LINUX_BUILDS
validate:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: configure
before_script:
- echo $CI_PIPELINE_ID
- echo "Validate ${CI_PROJECT_NAME} is correct and all necessary information is available."
script:
- >
if [ ! -d "${BUILD_DIRECTORY}" ]; then
cmake -E make_directory ${BUILD_DIRECTORY}
fi
after_script:
- echo "${BUILD_DIRECTORY} directory created"
artifacts:
name: "${CI_BUILD_NAME}"
expire_in: 1 hour
paths:
- $BUILD_DIRECTORY
initialize:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: configure
dependencies:
- validate
before_script:
- echo $CI_PIPELINE_ID
- echo "Initialize ${CI_PROJECT_NAME} build state, e.g. set properties or create directories."
script:
- uname -a
- cmake -E cmake_echo_color --cyan "$BUILD_DIRECTORY"
- cmake -E make_directory ${BUILD_DIRECTORY}
- cmake -E chdir $BUILD_DIRECTORY cmake -G "Unix Makefiles"
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_INSTALL_PREFIX=$HOME/${CI_PROJECT_NAME}_install/ ..
after_script:
- echo "Project initialization done"
artifacts:
name: "${CI_BUILD_NAME}"
expire_in: 1 hour
paths:
- $BUILD_DIRECTORY
generate-sources:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: configure
before_script:
- echo "Generate any source code for inclusion in compilation."
script:
- uname -a
after_script:
- echo "${CI_PROJECT_NAME} generation done"
process-sources:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: configure
before_script:
- echo "Process the source code, for example to filter any values, prettying..."
script:
- uname -a
after_script:
- echo "Sources processed done"
generate-resources:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: configure
before_script:
- echo "Generate ${CI_PROJECT_NAME} resources for inclusion in the package."
script:
- uname -a
after_script:
- echo "${CI_PROJECT_NAME} Resources generation done"
process-resources:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: configure
before_script:
- echo "Copy and process the resources into the destination directory, ready for packaging."
script:
- uname -a
after_script:
- echo "Resources process done"
compile:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: compile
before_script:
- echo "Compile the source code of the project."
script:
- hostname
# - cmake --build $BUILD_DIRECTORY --target all --clean-first -- -j$NUM_CORES
# - make -C $BUILD_DIRECTORY -j$NUM_CORES
# dependencies:
# - prettify-sources
after_script:
- echo "Compile the source code done."
artifacts:
name: "${CI_BUILD_REF_NAME}_${CI_BUILD_REF}"
expire_in: 1 day
paths:
- $BUILD_DIRECTORY/x86_64-Linux-GNU_GCC_*
process-compile:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: compile
before_script:
- echo "Post-process the generated files from compilation."
script:
- uname -a
after_script:
- echo "Post-process done."
generate-test-sources:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: unit-testing
before_script:
- echo "Generate any test source code for inclusion in compilation."
script:
- uname -a
after_script:
- echo "Test source code for inclusion in compilation done."
process-test-sources:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: unit-testing
before_script:
- echo "Process the test source code, for example to filter any values."
script:
- uname -a
after_script:
- echo "Test source code process done."
generate-test-resources:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: unit-testing
before_script:
- echo "Create resources for testing."
script:
- uname -a
after_script:
- echo "Resources for testing done."
process-test-resources:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: unit-testing
before_script:
- echo "Copy and process the resources into the test destination directory."
script:
- uname -a
after_script:
- echo "Done."
test-compile:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: unit-testing
before_script:
- echo "Compile the test source code into the test destination directory."
script:
- uname -a
dependencies:
- compile
after_script:
- echo "Test copilation done."
process-test:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: unit-testing
before_script:
- echo "Post-process the generated files from test compilation."
script:
- uname -a
after_script:
- echo "Done."
unit-testing:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
TEST_ARGS: "--iterration 1 --outputpath $BUILD_DIRECTORY --module dummy"
stage: unit-testing
before_script:
- echo "Run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployed."
script:
- hostname
# - make -C $BUILD_DIRECTORY test ARGS="--extra-verbose"
# - cmake --build $BUILD_DIRECTORY --target test
# - ctest $BUILD_DIRECTORY -V --build-and-test
# - cmake --build $BUILD_DIRECTORY --target test -- ARGS="$TEST_ARGS"
# - cmake -E env CTEST_OUTPUT_ON_FAILURE=TRUE cmake --build $BUILD_DIRECTORY --target test
# dependencies:
# - test-compile
after_script:
- echo " ${CI_PROJECT_NAME} Unit testing done."
prepare-package:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: package
before_script:
- echo "Perform any operations necessary to prepare a package before the actual packaging."
script:
- uname -a
after_script:
- echo "Done."
package:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: package
before_script:
- echo "Take the compiled code and package it in its distributable format, such as a ZIP."
script:
- uname -a
after_script:
- echo "Done."
artifacts:
name: "$CI_JOB_STAGE-$CI_COMMIT_REF_NAME"
paths:
- $BUILD_DIRECTORY
pre-integration-test:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: integration-testing
before_script:
- echo "Perform actions required before integration tests are executed. This may involve things such as setting up the required environment."
script:
- uname -a
after_script:
- echo "Done."
integration-test:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: integration-testing
before_script:
- echo "Process and deploy the package if necessary into an environment where integration tests can be run."
script:
- uname -a
# - cmake --build $BUILD_DIRECTORY --target integration-test
dependencies:
- test-compile
after_script:
- echo "Done."
post-integration-test:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: integration-testing
before_script:
- echo "Perform actions required after integration tests have been executed. This may including cleaning up the environment."
script:
- uname -a
after_script:
- echo "Done."
static-code-analysis:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: verify
before_script:
- echo "Run Static code analysis."
# - >
# if [ ! -d "${BUILD_DIRECTORY}" ]; then
# wget -q https://scan.coverity.com/download/linux64 --post-data "token=${COVERITY_TOKEN}&project=Zephyr" -O coverity-tool.tgz
# tar xvf coverity-tool.tgz;
# rm -f coverity-tool.tgz;
# mv cov-* cov-analysis;
# fi
# - export PATH=$PATH:${PWD}/cov-analysis/bin
script:
- uname -a
# - cov-configure --comptype gcc --compiler aarch64-linux-gnu-gcc --template
after_script:
- echo "Done."
dynamic-code-analysis:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: verify
before_script:
- echo "Run dynamic code analysis."
script:
- uname -a
- make --version
after_script:
- echo "Done."
source-code-linter:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: verify
before_script:
- echo "Check the C++ source code to analyze it for syntax errors and other faults."
script:
- uname -a
after_script:
- echo "Done."
source-code-coverage:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: verify
before_script:
- echo "Source code coverage analysis and statement-by-statement profiling."
script:
- uname -a
# coverage: /lines[.: ]*\d+.\d+%/
# coverage: - ^TOTAL.*\s+(\d+\%)$
# coverage: '/^TOTAL[\s\d]+\s+(\d+.\d+\%)\s*$/'
after_script:
- echo "Done."
artifacts:
paths:
- $BUILD_DIRECTORY/x86_64-Linux-GNU_GCC_*qa*.html
code-duplicate-detection:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: verify
before_script:
- echo "Static code analysis, copy-paste detection and..."
script:
- uname -a
after_script:
- echo "Done."
continuous-code-quality:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
SONAR_PROJECT_KEY: "<YOUR PROJECT KEY>"
SONAR_PROJECT_NAME: "$CI_PROJECT_NAME"
SONAR_PROJECT_VERSION: "$CI_BUILD_ID"
stage: verify
before_script:
- echo "Sonnar code source continuous Inspection."
script:
- echo "Sonar scanner should be installed"
# - sonar-scanner
# -Dsonar.source=.
# -Dsonar.host.url=$SONAR_URL
# -Dsonar.login=$SONAR_LOGIN
# -Dsonar.password=$PASSWD
# -Dsonar.projectKey="KEY"
# -Dsonar.projectVersion=$SONAR_PROJECT_VERSION
# -Dsonar.gitlab.projectName=$CI_PROJECT_ID
# -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA $CI_BUILD_RE
# -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME $CI_BUILD_REF_NAME
# -Dsonar.branch=$SONAR_BRANCH
# -Dsonar.analysis.mode=$SONAR_ANALYSIS_MODE
# -Dsonar.issuesReport.console.enable=true"
after_script:
- echo "Done."
artifacts:
paths:
- $BUILD_DIRECTORY
only:
- /^features\/.*/
except:
- tags
- schedule
publish-code-quality:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: deploy
before_script:
- echo "Publish code Inspection."
script:
- echo "Sonar scanner should be installed"
# - sonar-scanner
# -Dsonar.source=.
# -Dsonar.host.url=$SONAR_URL
# -Dsonar.login=$SONAR_LOGIN
# -Dsonar.gitlab.project=$CI_PROJECT_ID
# -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA
# -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
# -Dsonar.analysis.mode=publish
after_script:
- echo "Done."
artifacts:
paths:
- $BUILD_DIRECTORY
only:
- /^(master|develop)$/
except:
- tags
- schedules
dynamic-application-security-testing:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: verify
before_script:
- echo "Run dynamic code analysis."
script:
- uname -a
- make --version
after_script:
- echo "Done."
static-application-security-testing:
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: verify
allow_failure: true
tags: []
before_script: []
cache: {}
dependencies: []
before_script:
- echo "Run dynamic code analysis."
script:
- uname -a
- make --version
after_script:
- echo "Done."
run-time-application-security-protection:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: verify
before_script:
- echo "Run dynamic code analysis."
script:
- uname -a
- make --version
after_script:
- echo "Done."
binary-code-performance:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: verify
allow_failure: true
before_script:
- echo "Run any checks to verify the package is valid and meets quality criteria."
script:
- uname -a
- make --version
after_script:
- echo "Done."
verify:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: verify
before_script:
- echo "Run any checks to verify the package is valid and meets quality criteria."
script:
- uname -a
- make --version
after_script:
- echo "$CI_PROJECT_NAME Verification done! (${CI_RUNNER_ID})"
install:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: install
before_script:
- echo "Install the package into the local repository, for use as a dependency in other projects locally."
script:
- uname -a
- make --version
after_script:
- echo "Done."
artifacts:
paths:
- $BUILD_DIRECTORY
pre-site:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: site
when: always
before_script:
- echo "Execute processes needed prior to the actual project site generation."
script:
- uname -a
after_script:
- echo "Done."
only:
- master
except:
- schedules
artifacts:
paths:
- $BUILD_DIRECTORY
site:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: site
before_script:
- echo "Generate the project's site documentation."
script:
- uname -a
after_script:
- echo "Done."
only:
- master
except:
- schedules
artifacts:
paths:
- $BUILD_DIRECTORY
post-site:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: site
before_script:
- echo "Execute processes needed to finalize the site generation, and to prepare for site deployment."
script:
- uname -a
after_script:
- echo "Done."
only:
- master
except:
- schedules
artifacts:
paths:
- $BUILD_DIRECTORY
site-deploy:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: deploy
before_script:
- echo "Deploy the generated site documentation to the specified web server."
script:
- uname -a
after_script:
- echo "Done."
only:
- master
artifacts:
paths:
- $BUILD_DIRECTORY
pre-clean:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: clean
before_script:
- echo "Execute processes needed prior to the actual project cleaning."
script:
- uname -a
after_script:
- echo "Done."
artifacts:
paths:
- $BUILD_DIRECTORY
clean:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: clean
before_script:
- echo "Remove all files generated by the previous build."
script:
- uname -a
after_script:
- echo "Done."
artifacts:
paths:
- $BUILD_DIRECTORY
post-clean:
<<: *agent-who
variables:
JOB_DATE: "date +%Y-%m-%d-%H:%M:%S"
stage: clean
before_script:
- echo "Execute processes needed to finalize the project cleaning."
script:
- uname -a
after_script:
- echo "Done."
artifacts:
paths:
- $BUILD_DIRECTORY
end-to-end:
stage: deploy
script:
- echo "Invoking end to end ($CI_JOB_NAME in $CI_JOB_STAGE)"
environment:
name: qa/$CI_COMMIT_REF_NAME
url: https://dashboard.acme/status?id=staging/
only:
- /release\/.+/
- /hotfix\/.+/
deploy-to-staging:
stage: deploy
before_script:
- echo "Integration or release environment, copies the final package to the remote repository for sharing with other developers and projects."
- echo "Deploy to $ENVS ($CI_JOB_NAME in $CI_JOB_STAGE)"
script:
- cicd/deploy $CI_ENVIRONMENT_NAME
environment:
name: staging
url: https://dashboard.acme/status?id=staging/
when: manual
only:
# executes the build on every push to the branch:
- master
except:
- branches
artifacts:
expire_in: 1d
paths:
- "*.zip"
- "*.tgz"
deploy-to-production:
stage: deploy
before_script:
- echo "Deploy to $ENVS ($CI_JOB_NAME in $CI_JOB_STAGE)"
script:
- cicd/deploy $CI_ENVIRONMENT_NAME
environment:
name: production
url: https://dashboard.acme/status?id=production
when: manual
only:
# executes the build on every push to the branch:
- master
- tags
- /^v\d+\.\d+\.\d+$/
- /^v\d+\.\d+\.\d+([abc]\d*)?$/
- /^v\d+\.\d+\.\d+(?:(?:(?:\+|\.)?[a-zA-Z0-9]+)*)?$/
- /^v\d+\.\d+\.\d+(?:-(?:beta|rc)(?:(?:(?:\+|\.)?[a-zA-Z0-9]+)*)?)?$/
except:
- branches
artifacts:
expire_in: 1d
paths:
- "*.zip"
- "*.tgz"
deploy-review:
stage: deploy
tags:
- dds-ci
allow_failure: false
script:
- echo "Deploy a review app"
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://$CI_ENVIRONMENT_SLUG.review.acme
only:
- branches
except:
- master
- /^release-.*/
- /^production-.*/
artifacts:
paths:
- $BUILD_DIRECTORY
#Courtesy to https://rpadovani.com/open-mr-gitlab-ci
Open Merge Request:
# image: tmaier/gitlab-auto-merge-request
before_script: [] # We do not need any setup work, let's remove the global one (if any)
variables:
GIT_STRATEGY: none # We do not need a clone of the GIT repository to create a Merge Request
when: manual
stage: code-review
only:
- /^feature\/*/ # We have a very strict naming convention
script:
- >
HOST=${CI_PROJECT_URL} CI_PROJECT_ID=${CI_PROJECT_ID} CI_COMMIT_REF_NAME=${CI_COMMIT_REF_NAME}
GITLAB_USER_ID=${GITLAB_USER_ID} PRIVATE_TOKEN=${PRIVATE_TOKEN} ./autoMergeRequest.sh
- merge-request.sh # The name of the script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment