Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Continuous Integration with GitLab
Search
Ivan Nemytchenko
November 23, 2016
Programming
0
1.4k
Continuous Integration with GitLab
Ivan Nemytchenko
November 23, 2016
Tweet
Share
More Decks by Ivan Nemytchenko
See All by Ivan Nemytchenko
Code Topology Notation
inem
0
71
The Shape of a Service Object
inem
0
840
The Curse of Service Object
inem
0
280
Modern Make for modern (Rails) programmers
inem
0
78
Откуда берется сложность в Rails-проектах и куда бы её деть?
inem
0
270
Rails без боли и оверинжиниринга
inem
0
420
Painless Rails: наводим порядок в контроллерах
inem
0
260
Less Abstract! Surprising effects of expressing OOP in pictures
inem
1
580
Pure functions and side effects
inem
0
45
Other Decks in Programming
See All in Programming
Spatial Rendering for Apple Vision Pro
warrenm
0
110
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
140
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
280
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
100
Security_for_introducing_eBPF
kentatada
0
110
情報漏洩させないための設計
kubotak
3
360
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
5
750
php-conference-japan-2024
tasuku43
0
330
nekko cloudにおけるProxmox VE利用事例
irumaru
3
440
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
840
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6.1k
Unsuck your backbone
ammeep
669
57k
Building Adaptive Systems
keathley
38
2.3k
We Have a Design System, Now What?
morganepeng
51
7.3k
Building an army of robots
kneath
302
44k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
GitHub's CSS Performance
jonrohan
1030
460k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Git: the NoSQL Database
bkeepers
PRO
427
64k
It's Worth the Effort
3n
183
28k
Transcript
CONTINUOUS INTEGRATION WITH GITLAB IVAN NEMYTCHENKO, DEVELOPER ADVOCATE
MODERN SOFTWARE DEVELOPMENT PROCESS IS SPREAD ACROSS MANY TOOLS
Travis - GitHub - Trello - Slack
Bitbucket - Semaphore - Pivotal Tracker - HipChat
Jenkins - GitLab - Jira
None
None
None
None
None
None
None
None
None
None
None
CATGREP SOPHISTICATED TECHNOLOGIES INC. > file1.txt > file2.txt
REQUIREMENT #1 CONCATENATION RESULT SHOULD CONTAIN "HELLO WORLD"
cat file1.txt file2.txt | grep -q "Hello world"
None
RUN OUR FIRST TEST INSIDE CI
.gitlab-ci.yml
test: script: cat file1.txt file2.txt | grep -q 'Hello world'
None
None
REQUIREMENT #2 PACKAGE CODE BEFORE SENDING IT TO CUSTOMER
test: script: cat file1.txt file2.txt | grep -q 'Hello world'
package: script: cat file1.txt file2.txt | gzip > package.gz
None
MAKE RESULTS OF YOUR BUILD DOWNLOADABLE
test: script: cat file1.txt file2.txt | grep -q 'Hello world'
package: script: cat file1.txt file2.txt | gzip > packaged.gz artifacts: paths: - packaged.gz
None
RUN JOBS SEQUENTIALLY
stages: - test - package test: stage: test script: cat
file1.txt file2.txt | grep -q 'Hello world' package: stage: package script: cat file1.txt file2.txt | gzip > packaged.gz artifacts: paths: - packaged.gz
SPEEDING UP THE BUILD
#1: DUPLICATION
stages: - compile - test - package compile: stage: compile
script: cat file1.txt file2.txt > compiled.txt artifacts: paths: - compiled.txt test: stage: test script: cat compiled.txt | grep -q 'Hello world' package: stage: package script: cat compiled.txt | gzip > packaged.gz artifacts: paths: - packaged.gz
#2: RUBY 2.1 ????
LEARNING WHAT DOCKER IMAGE TO USE
image: alpine
image: alpine stages: - compile - test - package compile:
... test: ...
None
> defined 3 stages > pass files between stages >
downloadable artifacts > optimized execution time
REQUIREMENT #3 ISO INSTEAD OF GZIP
DEALING WITH COMPLEX SCENARIOS
None
image: alpine stages: - compile - test - package compile:
... test: ... pack-gz: stage: package script: cat compiled.txt | gzip > packaged.gz artifacts: paths: - packaged.gz pack-iso: stage: package script: - mkisofs -o ./packaged.iso ./compiled.txt artifacts: paths: - packaged.iso
None
DEALING WITH MISSING SOFTWARE/PACKAGES
INSTALL PACKAGE IN ALPINE LINUX apk add -U cdrkit
script: - apk add -U cdrkit - mkisofs -o ./packaged.iso
./compiled.txt
pack-iso: stage: package before_script: - apk add -U cdrkit script:
- mkisofs -o ./packaged.iso ./compiled.txt artifacts: paths: - packaged.iso
None
None
GITLAB REQUIREMENT #4 PUBLISH A SMALL WEBSITE WITH OUR PACKAGES
HTML + PACKAGES → AMAZON S3
aws s3 cp ./ s3://yourbucket/ --recursive
None
None
FIRST AUTOMATED DEPLOYMENT
> awscli can be installed using pip > pip goes
together with python
s3: image: python:latest stage: deploy script: - pip install awscli
- aws s3 cp ./ s3://yourbucket/ --recursive
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
variables: AWS_ACCESS_KEY_ID: "AKIAIOSFODNN7EXAMPLE" AWS_SECRET_ACCESS_KEY: “wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY” s3: image: python:latest stage: deploy
script: - pip install awscli - aws s3 cp ./ s3://yourbucket/ --recursive
KEEPING SECRET THINGS SECRET
SETTINGS --> VARIABLES
s3: image: python:latest stage: deploy script: - pip install awscli
- aws s3 cp ./ s3://yourbucket/ --recursive
So far so good:
REQUIREMENT #5 MORE THAN ONE DEVELOPER ON THE PROJECT
s3: image: python:latest stage: deploy script: - pip install awscli
- aws s3 cp ./ s3://yourbucket/ --recursive only: - master
None
REQUIREMENT #6 WE NEED A SEPARATE PLACE FOR TESTING
GITLAB PAGES
HOST WEBSITES ON GITLAB PAGES > your job should be
named "pages" > put your files into "public" folder > specify "artifacts" section with this "public" folder
HOST WEBSITES ON GITLAB PAGES > your job should be
named "pages" > put your files into "public" folder > specify "artifacts" section with this "public" folder HTTP://<USERNAME>.GITLAB.IO/<PROJECTNAME>
pages: stage: deploy image: alpine:latest script: - mkdir -p ./public
&& cp ./*.* ./public/ artifacts: paths: - public except: - master
s3: image: python:latest stage: deploy script: - pip install awscli
- aws s3 cp ./ s3://yourbucket/ --recursive only: - master pages: image: alpine:latest stage: deploy script: - mkdir -p ./public && cp ./*.* ./public/ artifacts: paths: - public except: - master
None
None
None
INTRODUCING ENVIRONMENTS
s3: environment: production image: python:latest stage: deploy script: - pip
install awscli - aws s3 cp ./ s3://$S3_BUCKET_NAME/ --recursive only: - master pages: image: alpine:latest environment: staging stage: deploy script: - mkdir -p ./public && cp ./*.* ./public/ artifacts: paths: - public except: - master
None
None
None
REQUIREMENT #7 DO NOT MESS UP PRODUCTION
SWITCHING TO MANUAL DEPLOYMENT
s3: image: python:latest stage: deploy script: - pip install awscli
- aws s3 cp ./ s3://yourbucket/ --recursive only: - master when: manual
SUMMARY 1. Deployment is just a set of commands 2.
You need to provide secret keys 3. You specify where which branches should go to 4. GitLab conserves the history of deployments 5. You can enable manual deployment
None
None
None
GO TO GITLAB.COM
@INEM
[email protected]
BIT.LY/GITLAB-CI1 BIT.LY/GITLAB-CI2