screwdriver.cdを使ってローカルでビルド

環境

macOS Catalina

前提

  • Docker Desktop がインストールされている
  • git コマンドが使える

手順

screwdriverクラスタをローカルに起動させる

$ python <(curl -L https://git.io/sd-in-a-box)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  9392  100  9392    0     0   7120      0  0:00:01  0:00:01 --:--:--  7120
🎁   Boxing up Screwdriver
👀   Checking prerequisites
🔐   Generating signing secrets
📤   Which SCM provider would you like to use? (github/gitlab/bitbucket) github
📦   Generating OAuth credentials

    Please create a new OAuth application on GitHub.com
    Go to https://github.com/settings/applications/new to start the process
    For 'Homepage URL' put http://192.168.0.2:9000
    For 'Authorization callback URL' put http://192.168.0.2:9001/v4/auth/login

    When done, please provide the following values:

    Client ID: 9baf4ee73bcbd1110a04
    Client Secret:

💾   Writing Docker Compose file
🚀   Screwdriver is ready to launch!

    Just run the following commands to get started!
      $ docker-compose pull
      $ docker-compose -p screwdriver up -d
      $ open http://192.168.0.2:9000

    Would you like to run them now? (y/n) y
Pulling api   ... done
Pulling ui    ... done
Pulling store ... done
Creating network "screwdriver_default" with the default driver
Creating screwdriver_store_1 ... done
Creating screwdriver_api_1   ... done
Creating screwdriver_ui_1    ... done

👍   Launched!

    A few more things to note:
      - To stop/reset Screwdriver
        $ docker-compose -p screwdriver down
      - If your internal IP changes, update the docker-compose.yml and your SCM OAuth application
      - In-a-box does not support Webhooks including PullRequests for triggering builds
      - To create your own cluster, see https://docs.screwdriver.cd/cluster-management/kubernetes
      - For help with this and more, find us on Slack at https://slack.screwdriver.cd

❤️   Screwdriver Crew

ui が立ち上がった。

screwdriver

Sign in with SCM Provider」リンクをクリックすると、以下のように権限認可画面が出る Authorize

状況確認

コンテナ
$ docker ps -a
CONTAINER ID        IMAGE                              COMMAND                  CREATED              STATUS                           PORTS                            NAMES
b42f1bb49d9f        screwdrivercd/ui:stable            "nginx -g 'daemon of…"   About a minute ago   Up About a minute                0.0.0.0:9000->80/tcp             screwdriver_ui_1
e18174d2bac6        screwdrivercd/screwdriver:stable   "docker-entrypoint.s…"   About a minute ago   Up About a minute                8080/tcp, 0.0.0.0:9001->80/tcp   screwdriver_api_1
eb1b350f4355        screwdrivercd/store:stable         "docker-entrypoint.s…"   About a minute ago   Up About a minute                0.0.0.0:9002->80/tcp             screwdriver_store_1
af6b538f8bee        centos:centos8                     "/sbin/init"             7 days ago           Exited (137) About an hour ago
イメージ
$ docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
centos                      centos8             0d120b6ccaa8        2 months ago        215MB
screwdrivercd/screwdriver   stable              bfc1a62afe5a        5 months ago        1.05GB
screwdrivercd/ui            stable              321c51c4e647        5 months ago        25.8MB
screwdrivercd/store         stable              692bb501be06        8 months ago        1.02GB

screwdrivercdだけで合計2GB以上もある。。

コンテナを停止

$ docker-compose -p screwdriver down
Stopping screwdriver_ui_1    ... done
Stopping screwdriver_api_1   ... done
Stopping screwdriver_store_1 ... done
Removing screwdriver_ui_1    ... done
Removing screwdriver_api_1   ... done
Removing screwdriver_store_1 ... done
Removing network screwdriver_default

コンテナ再確認

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
af6b538f8bee        centos:centos8      "/sbin/init"        29 hours ago        Exited (137) 25 hours ago                       centos8

メモ:コンテナ起動

$ docker-compose -p screwdriver up

Get Started

Getting Started with Screwdriver を参考し

$ git clone git@github.com:<YOUR_USERNAME_HERE>/quickstart-generic.git
$ cd quickstart-generic/
screwdriver.yaml

サンプルのscrewdriver.yamlにはコメント行が沢山あり、見づらいため、

$ sed -e '/^[\t ]*#/d' screwdriver.yaml 
---
shared:
  image: buildpack-deps

jobs:
  main:
    requires: [~pr, ~commit]
    steps:
      - export: export GREETING="Hello, world!"
      - hello: echo $GREETING
      - set-metadata: meta set example.coverage 99.95
  second_job:
    requires: main
    steps:
      - make_target: make greetings
      - get-metadata: meta get example
      - run_arbitrary_script: ./my_script.sh

でコメント行を除外して表示した。

Create a New Pipeline

screwdriver.cdのuiから、SCM(githubを選択していた)にログインして(OAuth認証)、Create Pipelineする。
下図にある[my_github_accoutn]部分は、実際に自分のアカウントが入る。 pipeline

Startボタンを押してビルド開始。 Start to build

以下のエラーが出てしまった

 (HTTP code 404) no such container - No such image: screwdrivercd/launcher:stable

参考資料