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
51
The Shape of a Service Object
inem
0
780
The Curse of Service Object
inem
0
270
Modern Make for modern (Rails) programmers
inem
0
77
Откуда берется сложность в Rails-проектах и куда бы её деть?
inem
0
270
Rails без боли и оверинжиниринга
inem
0
400
Painless Rails: наводим порядок в контроллерах
inem
0
250
Less Abstract! Surprising effects of expressing OOP in pictures
inem
1
570
Pure functions and side effects
inem
0
43
Other Decks in Programming
See All in Programming
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
Jakarta EE meets AI
ivargrimstad
0
580
CSC509 Lecture 11
javiergs
PRO
0
180
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.1k
Featured
See All Featured
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
A better future with KSS
kneath
238
17k
It's Worth the Effort
3n
183
27k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Become a Pro
speakerdeck
PRO
25
5k
Why Our Code Smells
bkeepers
PRO
334
57k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
We Have a Design System, Now What?
morganepeng
50
7.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
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