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.5k
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
87
The Shape of a Service Object
inem
0
950
The Curse of Service Object
inem
0
300
Modern Make for modern (Rails) programmers
inem
0
82
Откуда берется сложность в Rails-проектах и куда бы её деть?
inem
0
270
Rails без боли и оверинжиниринга
inem
0
460
Painless Rails: наводим порядок в контроллерах
inem
0
260
Less Abstract! Surprising effects of expressing OOP in pictures
inem
1
600
Pure functions and side effects
inem
0
46
Other Decks in Programming
See All in Programming
Immutable ActiveRecord
megane42
0
140
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
220
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
850
ペアーズでの、Langfuseを中心とした評価ドリブンなリリースサイクルのご紹介
fukubaka0825
2
330
pylint custom ruleで始めるレビュー自動化
shogoujiie
0
120
ファインディの テックブログ爆誕までの軌跡
starfish719
2
1.1k
GoとPHPのインターフェイスの違い
shimabox
2
190
ファインディLT_ポケモン対戦の定量的分析
fufufukakaka
0
740
楽しく向き合う例外対応
okutsu
0
150
法律の脱レガシーに学ぶフロントエンド刷新
oguemon
5
740
Linux && Docker 研修/Linux && Docker training
forrep
24
4.5k
Conform を推す - Advocating for Conform
mizoguchicoji
3
690
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
6
240
Side Projects
sachag
452
42k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.4k
Scaling GitHub
holman
459
140k
BBQ
matthewcrist
87
9.5k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Facilitating Awesome Meetings
lara
52
6.2k
Designing on Purpose - Digital PM Summit 2013
jponch
117
7.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
GitHub's CSS Performance
jonrohan
1030
460k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.2k
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