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

GitもCIもテストもないプロジェクトでデプロイを自動化するまでの道 / rebuild of...

GitもCIもテストもないプロジェクトでデプロイを自動化するまでの道 / rebuild of DevOps

LT for FORCIA Meetup #1 〜DevOpsやっていかnight〜
https://forcia.connpass.com/event/165684/

Taiju Aoki

March 10, 2020
Tweet

More Decks by Taiju Aoki

Other Decks in Programming

Transcript

  1. ࢲ͸୭ʁ blue (@blue_1617) https://blue0513.github.io/show_room/ 2 Rails, JavaScript, Scala etc ‣

    ΤϜεϦʔ Ϋϥ΢υిࢠΧϧςνʔϜॴଐ ͨ·ʹ C# ΍ DevOps ܥ΋΍ΔΑ ‣ ৽ଔ 2 ೥໨ͷͽ͔ͬͽ͔ΤϯδχΞ ‣ OSS ׆ಈ slackdeck-proto : Slack ͷ TweetDeck ෩ Viewer phantom-inline-comment: Emacs ͷ package
  2. མԼࡿ෦ୂͱͯ͠ͷϦϏϧυ 7 100%֎஫͍ͯͨ͠ϓϩμΫτΛ಺੡Խ͢Δ ‣ ϓϩδΣΫτͷϛογϣϯ blueʮC#ʁWindows FormsʁWindows ʁʯ ‣ C#

    σεΫτοϓΞϓϦʢWindows Formsʣ ͳΜͯ΋ͷ͸ଘࡏ͠ͳ͍ ‣ GitɺϢχοτςετɺ࢓༷ॻɺCI VPoE & ྺઓͷ໠ऀ & blue ‣ ։ൃʹܞΘΔΤϯδχΞ͸3໊ͷΈ
  3. Git؅ཧʹ͢Δ 12 GitLab ʹΤΠ΍Ͱ pushʂ VSS GitLab ໰୊: VSS ؅ཧʢVisual

    Studioͷιʔείʔυ؅ཧιϑτʣ جຊํ਑: աڈΛৼΓฦΒͣɺࡶʹ Git ʹ͋͛Δ
  4. Git؅ཧʹ͢Δ 13 GitLab ʹΤΠ΍Ͱ pushʂ Git ͱ͍͏ϞμϯͳπʔϧΛ࢖͑ΔΑ͏ʹͳͬͨ VSS GitLab ໰୊:

    VSS ؅ཧʢVisual Studioͷιʔείʔυ؅ཧιϑτʣ ※ major version ͸ 2 ੈ୅લ جຊํ਑: աڈΛৼΓฦΒͣɺࡶʹ Git ʹ͋͛Δ
  5. Git؅ཧʹ͢Δ 14 GitLab ʹΤΠ΍Ͱ pushʂ Git ͱ͍͏ϞμϯͳπʔϧΛ࢖͑ΔΑ͏ʹͳͬͨ VSS GitLab ໰୊:

    VSS ؅ཧʢVisual Studioͷιʔείʔυ؅ཧιϑτʣ ※ major version ͸ 2 ੈ୅લ جຊํ਑: աڈΛৼΓฦΒͣɺࡶʹ Git ʹ͋͛Δ Git ͕࢖͑ΔΑ͏ʹͳͬͨΑʂ
  6. Git؅ཧʹ͢Δ ~·ͱΊ~ 15 ‣ VSS ͔Β Git ؅ཧ ʹҠߦͨ͠ ‣

    ੒Ռ ‣ ൿ݃ ~খ͘͞͸͡Ίͨ~ ‣ ❌ VSS ͷྺ࢙Λอ࣋͢Δ ‣ ⭕ ͍͑΍Ͱશ Pushʂ ‣ ❌ GitLab ͷόʔδϣϯΞοϓ ‣ ࠷খ޻਺Ͱ࣮ݱͰ͖Δख๏Λ໛ࡧͨ͠
  7. GitLab ͷ Version Λ͋͛Δ 18 ‣ CI ͷػೳ΍ MR ͷػೳ͕଍Γͳ͍

    ໰୊: major version ͕ 2 ੈ୅લ ‣ ͜ͷ··ϏϋΠϯυ͢Δͷ͸ϚζΠ......
  8. GitLab ͷ Version Λ͋͛Δ 19 GitLab جຊํ਑: खஈ͸໰Θͣ Version Λ͋͛Δʢୈ1ճʣ

    1. ૉ௚ʹ Version Λ͋͛Δ ໰୊: major version ͕ 2 ੈ୅લ
  9. GitLab ͷ Version Λ͋͛Δ 20 ※ ୭͕ɺͲ͏΍ͬͯೖΕͨͷ͔ෆ໌ ※ ڪΒ͘ΧελϚΠζͯ͋͠Δ GitLab

    جຊํ਑: खஈ͸໰Θͣ Version Λ͋͛Δʢୈ1ճʣ 1. ૉ௚ʹ Version Λ͋͛Δ ໰୊: major version ͕ 2 ੈ୅લ
  10. GitLab ͷ Version Λ͋͛Δ 21 2. چ GitLab ͔Β Project

    Export ͢Δ چ GitLab ৽ GitLab 1. ৽͍͠ Version ͷ GitLab ΛݐͯΔ جຊํ਑: खஈ͸໰Θͣ Version Λ͋͛Δʢୈ1ճʣ ໰୊: major version ͕ 2 ੈ୅લ
  11. GitLab ͷ Version Λ͋͛Δ 22 2. چ GitLab ͔Β Project

    Export ͢Δ چ GitLab ৽ GitLab 1. ৽͍͠ Version ͷ GitLab ΛݐͯΔ جຊํ਑: खஈ͸໰Θͣ Version Λ͋͛Δʢୈ1ճʣ ໰୊: major version ͕ 2 ੈ୅લ ※ major version ͕཭Ε͍ͯΔͱ Export/Import ෆՄ
  12. GitLab ͷ Version Λ͋͛Δ 23 2. چ GitLab ͔Β Project

    Λ Push ͢Δ 1. ৽͍͠ Version ͷ GitLab ΛݐͯΔ جຊํ਑: खஈ͸໰Θͣ Version Λ͋͛Δʢୈ1ճʣ ໰୊: major version ͕ 2 ੈ୅લ چ GitLab ৽ GitLab Push
  13. GitLab ͷ Version Λ͋͛Δ 24 2. چ GitLab ͔Β Project

    Λ Push ͢Δ 1. ৽͍͠ Version ͷ GitLab ΛݐͯΔ جຊํ਑: खஈ͸໰Θͣ Version Λ͋͛Δʢୈ1ճʣ ໰୊: major version ͕ 2 ੈ୅લ چ GitLab ৽ GitLab Push ※ CI ΍ Wiki ͳͲ͸Ҿ͖ܧ͛ͳ͍
  14. GitLab ͷ Version Λ͋͛Δ 25 2. چ GitLab ͔Β Project

    Λ Push ͢Δ چ GitLab ৽ GitLab 1. ৽͍͠ Version ͷ GitLab ΛݐͯΔ Push جຊํ਑: खஈ͸໰Θͣ Version Λ͋͛Δʢୈ1ճʣ ໰୊: major version ͕ 2 ੈ୅લ ※ CI ΍ Wiki ͳͲ͸Ҿ͖ܧ͛ͳ͍ CI ΋ Wiki ΋ͳ͍͔Βؔ܎ͳ͍ʂʂʂʂ
  15. GitLab ͷ Version Λ͋͛Δ 26 2. چ GitLab ͔Β Project

    Λ Push ͢Δ چ GitLab جຊํ਑: खஈ͸໰Θͣ Version Λ͋͛Δʢୈ3ճʣ ৽ GitLab 1. ৽͍͠ Version ͷ GitLab ΛݐͯΔ Push ※ CI ΍ Wiki ͳͲ͸Ҿ͖ܧ͛ͳ͍ CI ΋ Wiki ΋ͳ͍͔Βؔ܎ͳ͍ʂʂʂʂ GitLab ͷ Version ͕͋ͬͨʂ
  16. GitLab ͷ Version Λ͋͛Δ ~·ͱΊ~ 27 ‣ GitLab ͷόʔδϣϯ͕͕͋Γ։ൃ͕εϜʔζʹ ‣

    ੒Ռ ‣ ൿ݃ ~খ͘͞͸͡Ίͨ~ ‣ ❌ GitLab Λ৽ͨͯ͘͠Δ ‣ ࠷খ޻਺Ͱ࣮ݱͰ͖Δख๏Λ໛ࡧͨ͠ ‣ ❌ GitLab Λਅ໘໨ʹόʔδϣϯΞοϓ ‣ ⭕ طଘͷ GitLab ʹ Pushʂ
  17. CI؀ڥΛ࡞Δ ~ Runner on VM ~ 32 VM ʹ Windows

    Λ͍Εͯ GitLab Runner ཱͯΔ جຊઓུ: ԼखʹؤுΒͳ͍ vmware fusion GitLab Runner windows Install Install
  18. CI؀ڥΛ࡞Δ ~ Runner on VM ~ 33 VM ʹ Windows

    Λ͍Εͯ GitLab Runner ཱͯΔ جຊઓུ: ԼखʹؤுΒͳ͍ vmware fusion GitLab Runner windows Excel ʹॻ͍ͯ͋Δ Windows License Key ݹ͍໰୊ DNS ղܾ͠ͳ͍໰୊ vmware fusion Install Install
  19. CI؀ڥΛ࡞Δ ~ Runner on VM ~ 34 VM ʹ Windows

    Λ͍Εͯ GitLab Runner ཱͯΔ جຊઓུ: ԼखʹؤுΒͳ͍ vmware fusion GitLab Runner windows Excel ʹॻ͍ͯ͋Δ Windows License Key ݹ͍໰୊ DNS ղܾ͠ͳ͍໰୊ vmware fusion ?? CI ༻ͷ؀ڥ͕Ͱ͖ͨʂ
  20. CI؀ڥΛ࡞Δ ~·ͱΊ~ 35 ‣ CI ؀ڥΛ࡞ͬͨ ‣ ੒Ռ ‣ ൿ݃

    ~খ͘͞͸͡Ίͨ~ ‣ ❌ Docker on Windows ‣ ࠷খ޻਺Ͱ࣮ݱͰ͖Δख๏Λ໛ࡧͨ͠ ‣ ❌ WSL/WSL2 ‣ ⭕ Windows VM ʹ GitLab Runner ݐ଄
  21. PowerShellͱ͸ 41 ‣ MS ͕։ൃ֦ͨ͠ுՄೳͳ CLI γΣϧ͓ΑͼεΫϦϓτݴޠ PowerShell ‣ ه๏͕ඍົʹ

    Bash ͱҟͳΔ ‣ GitLab CI Ͱ͸ม਺ల։ͷه๏͕ҟͳΔ ← ͔ͳΓ໽հʢsed ͳͲ͕࢖͑ͳ͍ʣ
  22. PowerShellͱ͸ 42 ‣ MS ͕։ൃ֦ͨ͠ுՄೳͳ CLI γΣϧ͓ΑͼεΫϦϓτݴޠ PowerShell ‣ ه๏͕ඍົʹ

    Bash ͱҟͳΔ ‣ GitLab CI Ͱ͸ม਺ల։ͷه๏͕ҟͳΔ < ͔ͳΓ໽հʢsed ͳͲ͕࢖͑ͳ͍ʣ എʹෲ͸୅͑ΒΕΜ.... ͓ͱͳ͘͠ॻ͜͏ GitLab Runner on PowerShell ര஀
  23. CIΛಈ͔͢ ~·ͱΊ~ 43 ‣ CI ͕ճΓ࢝Ίͨ ‣ ੒Ռ ‣ ൿ݃

    ~খ͘͞͸͡Ίͨ~ ‣ ❌ ϢχοτςετΛճ͢ ‣ ࠷খ޻਺Ͱ࣮ݱͰ͖Δख๏Λ໛ࡧͨ͠ ‣ ❌ PowerShell ͔ΒҠߦ͢Δ ‣ ⭕ ϏϧυςετͷΈΛճ͢ ‣ ⭕ PowerShell Ͱಈ͔͢
  24. VSTest NUnit XUnit ೔ͷ໨Λݟͳ͍ Test Framework ͨͪ ςετΛ࡞Δ 47 ಉ྅

    ͞΋͋ΓͳΜ Α͘ಈ͍ͯΔͳ ໰୊: Test Coverage ΄΅ 0 %
  25. ςετΛ࡞Δ 51 ‣ XUnit ΍ NUnit Ͱ͸ͳ͘ γϯϓϧʹ VSTest Λ࢖͏

    جຊํ਑: ৽نϩδοΫʹରͯ͠ॻ͍ͯΈΔ ‣ طଘͷϩδοΫ͸ͱΓ͋͑ͣ์ஔ طଘϩδοΫ ৽نϩδοΫ VSTest NUnit XUnit Ϣχοτςετര஀ʂ
  26. ςετΛ࡞Δ ~·ͱΊ~ 52 ‣ Ϣχοτςετ͕ճΓ࢝Ίͨ ‣ ੒Ռ ‣ ൿ݃ ~খ͘͞͸͡Ίͨ~

    ‣ ❌ طଘͷϩδοΫͷςετΛॻ͘ ‣ ࠷খ޻਺Ͱ࣮ݱͰ͖Δख๏Λ໛ࡧͨ͠ ‣ ❌ ςετϑϨʔϜϫʔΫΛબผ͢Δ ‣ ⭕ ৽نϩδοΫͷςετΛॻ͖࢝ΊΔ ‣ ⭕ ඪ४ͷςετϑϨʔϜϫʔΫΛ࢖͏
  27. σϓϩΠΛ͢Δ 58 1. DBͷ UserId, Pass ΍ม਺౳Λ sed Ͱஔ׵ 2.

    ClickOnce ഑෍͢ΔͨΊʹϚχϑΣετॺ໊ 3. ؀ڥ͝ͱʹڞ༗σΟϨΫτϦʹखಈίϐʔ ‣ ؀ڥ͝ͱʹ ID, Pass ͕ҟͳΔ ‣ ؀ڥ਺: QAɺStagingɺPreReleaseɺProd ͷ4͕ͭ͋Δ ‣ BatchαʔόɺOnlineαʔόͰ ID, Pass ͕ҟͳΔ ‣ Mage ίϚϯυʹΑΔΞϓϦ΁ͷॺ໊͕ඞཁ ‣ ূ໌ॻ͕ProdͱͦΕҎ֎ͰҟͳΔ 0. ϩʔΧϧͰ ClickOnce ΞϓϦͱͯ͠Ϗϧυ ~ ղಡ݁Ռ ~
  28. σϓϩΠΛ͢Δ 59 3. ؀ڥ͝ͱʹڞ༗σΟϨΫτϦʹखಈίϐʔ ‣ ؀ڥ͝ͱʹ ID, Pass ͕ҟͳΔ ‣

    ؀ڥ਺: QAɺStagingɺPreReleaseɺProd ͷ4͕ͭ͋Δ ‣ BatchαʔόɺOnlineαʔόͰ ID, Pass ͕ҟͳΔ ‣ Mage ίϚϯυʹΑΔΞϓϦ΁ͷॺ໊͕ඞཁ ‣ ূ໌ॻ͕ProdͱͦΕҎ֎ͰҟͳΔ sed ͸ଘࡏ͠ͳ͍ͷͰ૭ͷైͰ exe Λ DL ݹͷ MS ͷٕज़ ؀ڥ͸ 4 ͭ͋Δ݅ 0. ϩʔΧϧͰ ClickOnce ΞϓϦͱͯ͠Ϗϧυ 1. DBͷ UserId, Pass ΍ม਺౳Λ sed Ͱஔ׵ 2. ClickOnce ഑෍͢ΔͨΊʹϚχϑΣετॺ໊ ~ ղಡ݁Ռ ~ ม਺͍ͬͺ͍͋ΔΜ͕ͩʁʁ
  29. σϓϩΠΛ͢Δ 60 3. ؀ڥ͝ͱʹڞ༗σΟϨΫτϦʹखಈίϐʔ ‣ ؀ڥ͝ͱʹ ID, Pass ͕ҟͳΔ ‣

    ؀ڥ਺: QAɺStagingɺPreReleaseɺProd ͷ4͕ͭ͋Δ ‣ BatchαʔόɺOnlineαʔόͰ ID, Pass ͕ҟͳΔ ‣ Mage ίϚϯυʹΑΔΞϓϦ΁ͷॺ໊͕ඞཁ ‣ ূ໌ॻ͕ProdͱͦΕҎ֎ͰҟͳΔ sed ͸ଘࡏ͠ͳ͍ͷͰ૭ͷࣾͰ exe Λ DL ݹͷ MS ͷٕज़ ؀ڥ͸ 4 ͭ͋Δ݅ 0. ϩʔΧϧͰ ClickOnce ΞϓϦͱͯ͠Ϗϧυ 1. DBͷ UserId, Pass ΍ม਺౳Λ sed Ͱஔ׵ 2. ClickOnce ഑෍͢ΔͨΊʹϚχϑΣετॺ໊ ~ ղಡ݁Ռ ~ ม਺͍ͬͺ͍͋ΔΜ͕ͩʁʁ σϓϩΠ׬શཧղʂ ʢଟ෼ʣ
  30. σϓϩΠΛ͢Δ ~·ͱΊ~ 61 ‣ ಺੡Խ͔ͯ͠ΒॳͷσϓϩΠΛͨ͠ ‣ ੒Ռ ‣ ൿ݃ ~খ͘͞͸͡Ίͨ~

    ‣ ❌ 1͔ΒσϓϩΠख๏Λཱ֬ͤ͞Δ ‣ ࠷খ޻਺Ͱ࣮ݱͰ͖Δख๏Λ໛ࡧͨ͠ ‣ ❌ σϓϩΠεΫϦϓτΛϦϑΝΫλ ‣ ⭕ ֎஫ઌͷσϓϩΠख๏Λ౿ऻ
  31. 67 جຊํ਑: GitBash Λ࢖͏ GitBash Git for Windows provides a

    BASH emulation used to run Git from the command line. *NIX users should feel right at home, as the BASH emulation behaves just like the "git" command in LINUX and UNIX environments. Windows Ͱͷ Bash ΤϛϡϨʔλʢlike LINUX, UNIXʣ σϓϩΠΛ൒ࣗಈԽ͢Δ
  32. σϓϩΠΛ൒ࣗಈԽ͢Δ ~·ͱΊ~ 71 ‣ σϓϩΠखॱΛεΫϦϓτʹͯࣗ͠ಈԽ ‣ ੒Ռ ‣ ൿ݃ ~খ͘͞͸͡Ίͨ~

    ‣ ❌ CI ʹ৐ͤΔ ‣ ࠷খ޻਺Ͱ࣮ݱͰ͖Δख๏Λ໛ࡧͨ͠ ‣ ⭕ खͰ࣮ߦ͢Δ
  33. CIͰσϓϩΠ͢Δ 74 ໰୊: CI ͸ PowerShell Ͱಈ࡞͢Δ Bash WindowsBatch PowerShell

    Win # https://docs.gitlab.com/runner/executors/ GitLab Supported Executor ͭ·Γ......ʁ
  34. CIͰσϓϩΠ͢Δ 75 ໰୊: CI ͸ PowerShell Ͱಈ࡞͢Δ ※ σϓϩΠ ShellScript

    Λ࣮ߦͰ͖ͳ͍ PowerShell ࣮ߦ σϓϩΠShellScript
  35. CIͰσϓϩΠ͢Δ 78 جຊํ਑: GitBash Λ Executor ͱͯ͠࢖͏ https://stackoverflow.com/questions/41733406/windows-gitlab-ci-runner-using-bash [[runners]] ....

    shell = "powershell" .... [[runners]] .... shell = "bash" .... Step 1. GitLab Runner ͷ config Λมߋ Failed to start process: exec: "bash": executable file not found in %PATH%
  36. CIͰσϓϩΠ͢Δ 80 جຊํ਑: GitBash Λ Executor ͱͯ͠࢖͏ https://stackoverflow.com/questions/41733406/windows-gitlab-ci-runner-using-bash @"C:¥Path¥To¥ git-bash.exe

    " -l Step 2. bash.cmd Λ࡞੒ or มߋ bash.cmd @"C:¥Path¥To¥ bash.exe " -l bash.cmd (batchϑΝΠϧ) ....... connection timeout ......
  37. CIͰσϓϩΠ͢Δ ~Another 1~ 85 جຊํ਑: GitBash Λ Executor ͱͯ͠࢖͏ ࣮ߦ

    σϓϩΠShellScript GitBash manual job ʹΑΓ σϓϩΠ؀ڥΛબ୒
  38. CIͰσϓϩΠ͢Δ ~Another 2~ 86 جຊํ਑: GitBash Λ Executor ͱͯ͠࢖͏ ࣮ߦ

    σϓϩΠShellScript GitBash manual job ʹΑΓ σϓϩΠ؀ڥΛબ୒ σϓϩΠ௨஌
  39. CIͰσϓϩΠ͢Δ ~·ͱΊ~ 87 ‣ CI ͰσϓϩΠͰ͖ΔΑ͏ʹͳͬͨ ‣ ੒Ռ ‣ ൿ݃

    ~খ͘͞͸͡Ίͨ~ ‣ ⭕ εΫϦϓτΛ࢖͍ճ࣮ͯ͠ߦ ‣ ࠷খ޻਺Ͱ࣮ݱͰ͖Δख๏Λ໛ࡧͨ͠ ‣ ⭕ Slack ࿈ܞ΍ͦͷଞػೳ͸ผ MR Ͱ
  40. 89 ·ͱΊ ‣ ࠷ળखͰ͸ͳ͍͔΋͠Εͳ͍͕ɺݱ࣮ղΛ୳͍ͯ͘͠ ‣ খ͘͞Ͱ΋͍͍͔ΒɺલʹਐΜͰվળΛਐΊΔํ਑ ‣ ϦϏϧυͰॏཁͩͱײͨ͜͡ͱ ‣ ୡ੒ͨ͜͠ͱ

    ‣ Git ΍ GitLab Λ࢖ͬͨ։ൃ؀ڥΛ੔͑ͨ ‣ CI Λߏஙͯ҆͠શʹ։ൃΛਐΊΒΕΔΑ͏ʹͨ͠ ‣ σϓϩΠΛࣗಈԽͨ͠ ‣ ॳظεςʔλε ‣ GitɺCI/CD ͷ࢓૊Έ ແ͠