Created
December 4, 2019 15:37
-
-
Save zdtsw/43f7cc9d79c52cd58e6b066c9d83fd18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Below is a simple exmple of how to use gitlab ci | |
you need to have two different runner: one windows with tag "windows" and one linux with tag "linux" | |
the pipeline basically try to do | |
-some go static check | |
-build go app on both window and linux parallel | |
-run int test | |
-deploy goapp to qa1 and qa2 parallel | |
-deploy to production | |
there is a lot room to improve this, say, qa1 could be a windows qa2 could be a linux, say, we do not really need runner but can use | |
golang docker image instead etc etc | |
but the purpose of this , is to show how gitlab-ci works and see if it is an option to replace our jenkins pipeline | |
############################################################################################################## | |
>$git_root/.gitlab-ci.yml | |
variables: | |
REPO_NAME: git.comhem.com/devliery-tools/dashing-delivery-dashboard-onk8 | |
before_script: | |
- echo "start job at :" `date` | |
- echo "workspace is:" `pwd` | |
after_script: | |
- echo "done job at :" `date` | |
stages: | |
- check | |
- build | |
- integration | |
- deployci | |
- deployqa | |
- prod | |
syntaxcheck: | |
stage: check | |
script: | |
- mkdir -p $GOPATH/src/$(dirname $REPO_NAME) | |
- ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME | |
- cd $GOPATH/src/$REPO_NAME | |
- go fmt | |
- go vet | |
- go lint | |
windows build: | |
stage: build | |
tags: | |
- windows | |
script: | |
- GOOS=windows GOARCH=386 go build -o gojira-amd32 | |
- GOOS=windows GOARCH=amd64 go build -o gojira-amd64 | |
only: | |
- master | |
Linux build: | |
stage: build | |
tags: | |
- linux | |
script: | |
GOOS=linux GOARCH=amd64 go build -o gojira | |
only: | |
refs: | |
- master | |
intergration test: | |
stage: integration | |
script: | |
- echo "doing some test thing" | |
deploy ci1: | |
variables: | |
env: ci1 | |
stage: deployci | |
script: | |
- echo "deploy it to ${env} " | |
deploy qa2: | |
variables: | |
env: qa2 | |
stage: deployqa | |
script: | |
- echo "deploy it to ${env} " | |
deploy qa1: | |
variables: | |
env: qa1 | |
stage: deployqa | |
script: | |
- echo "deploy it to ${env} " | |
deploy prod: | |
variables: | |
env: prod | |
stage: prod | |
script: | |
- echo "deploy it to ${env}" | |
after_script: | |
- echo "production deploy done" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment