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
81
The Shape of a Service Object
inem
0
930
The Curse of Service Object
inem
0
290
Modern Make for modern (Rails) programmers
inem
0
81
Откуда берется сложность в Rails-проектах и куда бы её деть?
inem
0
270
Rails без боли и оверинжиниринга
inem
0
450
Painless Rails: наводим порядок в контроллерах
inem
0
260
Less Abstract! Surprising effects of expressing OOP in pictures
inem
1
590
Pure functions and side effects
inem
0
45
Other Decks in Programming
See All in Programming
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
8
1.3k
CNCF Project の作者が考えている OSS の運営
utam0k
5
620
Swiftコンパイラ超入門+async関数の仕組み
shiz
0
190
Package Traits
ikesyo
2
230
“あなた” の開発を支援する AI エージェント Bedrock Engineer / introducing-bedrock-engineer
gawa
10
1.4k
ゼロからの、レトロゲームエンジンの作り方
tokujiros
3
1.2k
watsonx.ai Dojo #6 継続的なAIアプリ開発と展開
oniak3ibm
PRO
0
270
ecspresso, ecschedule, lambroll を PipeCDプラグインとして動かしてみた (プロトタイプ) / Running ecspresso, ecschedule, and lambroll as PipeCD Plugins (prototype)
tkikuc
2
2.3k
HTML/CSS超絶浅い説明
yuki0329
0
210
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
600
ASP.NET Core の OpenAPIサポート
h455h1
0
160
富山発の個人開発サービスで日本中の学校の業務を改善した話
krpk1900
3
310
Featured
See All Featured
KATA
mclloyd
29
14k
A better future with KSS
kneath
238
17k
Navigating Team Friction
lara
183
15k
Facilitating Awesome Meetings
lara
51
6.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Embracing the Ebb and Flow
colly
84
4.5k
It's Worth the Effort
3n
184
28k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
20
2.4k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.4k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Code Reviewing Like a Champion
maltzj
521
39k
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