Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuous Integration with GitLab

Continuous Integration with GitLab

Ivan Nemytchenko

November 23, 2016
Tweet

More Decks by Ivan Nemytchenko

Other Decks in Programming

Transcript

  1. test: script: cat file1.txt file2.txt | grep -q 'Hello world'

    package: script: cat file1.txt file2.txt | gzip > package.gz
  2. 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
  3. 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
  4. 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
  5. > defined 3 stages > pass files between stages >

    downloadable artifacts > optimized execution time
  6. 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
  7. pack-iso: stage: package before_script: - apk add -U cdrkit script:

    - mkisofs -o ./packaged.iso ./compiled.txt artifacts: paths: - packaged.iso
  8. s3: image: python:latest stage: deploy script: - pip install awscli

    - aws s3 cp ./ s3://yourbucket/ --recursive
  9. s3: image: python:latest stage: deploy script: - pip install awscli

    - aws s3 cp ./ s3://yourbucket/ --recursive
  10. s3: image: python:latest stage: deploy script: - pip install awscli

    - aws s3 cp ./ s3://yourbucket/ --recursive only: - master
  11. HOST WEBSITES ON GITLAB PAGES > your job should be

    named "pages" > put your files into "public" folder > specify "artifacts" section with this "public" folder
  12. 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>
  13. pages: stage: deploy image: alpine:latest script: - mkdir -p ./public

    && cp ./*.* ./public/ artifacts: paths: - public except: - master
  14. 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
  15. 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
  16. s3: image: python:latest stage: deploy script: - pip install awscli

    - aws s3 cp ./ s3://yourbucket/ --recursive only: - master when: manual
  17. 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