Wercker | The wercker command line interface
概要
Wercker command line interface として提供されている Python 製の
wercker-cli を利用して、 CLI 経由で Wercker を操作します
インストール
- pip のインストール(Ubuntu)
$ sudo apt-get install python-dev
$ sudo apt-get install python-setuptools
$ sudo apt-get install python-pip
$ pip --version
pip 1.0 from /usr/lib/python2.7/dist-packages (python 2.7)
- wercker のインストール
$ sudo pip install wercker
$ wercker --version
-----------------------
welcome to wercker-cli
-----------------------
version 0.9.0
GitHub 認証を利用している場合
GitHub でユーザー認証している場合は、別途パスワードを設定しないと CLI でログインできない模様。
-
該当 Issue はこちら
-
Signin page で Forgot your password? を選択してメールを受信し、メールに記載されたURLからパスワードを設定する
Commands
command | description |
---|---|
create | リポジトリを wercker に登録 |
link | Wercker に登録済みのリポジトリとリンクする(.wercker を取得) |
status | ビルド状況を表示する |
deploy | デプロイを実行する |
builds | ビルド履歴を表示する |
open | カレントプロジェクトの Wercker 画面をブラウザで開く |
open targets | カレントプロジェクトの デプロイターゲットをブラウザで開く |
queue | Wercker のキューを表示 |
apps | Wercker に登録済みのアプリケーションを全て表示 |
login | Wercker に login する。 |
logout | Wercker から logout する。 |
[targets add](#targets add) | git remote に設定されている heroku をデプロイターゲットに追加する |
[targets list](#targets list) | デプロイターゲットの一覧を表示 |
[targets details](#targets details) | デプロイターゲットの一覧を表示 + 指定したデプロイターゲットをブラウザで開く |
update | wercker cli を update する |
Usage
create
git repository の root ディレクトリで実行し、対話形式で Wercker への登録情報を入力します
$ cd gottani
$ wercker create
-----------------------
welcome to wercker-cli
-----------------------
About to create an application on wercker.
This consists of the following steps:
1. Configure application
2. Setup keys
3. Add a deploy target (0 heroku targets detected)
4. Trigger initial build
Step 1. Configure application
-------------
1 repository location(s) found...
Please choose one of the following options:
(1) git@bitbucket.org:some_user_name/gottani.git
Make your choice (1=default):
bitbucket repository detected...
Selected repository url is git@bitbucket.org:some_user_name/gottani.git
Step 2.
-------------
In order to clone the repository on wercker, an ssh key is needed. A new/unique
key can be generated for each repository. There 3 ways of using ssh keys on
wercker:
1. Automatically add a deploy key [recommended]
2. Use the checkout key, wercker uses for public projects.
3. Let wercker generate a key, but allow add it manually to github/bitbucket.
(needed when using git submodules)
For more information on this see: http://etc...
Options:(enter=1):
Retrieving a new ssh-key.
done.
Adding deploy key to repository:
Creating a new application
done.
In the root of this repository a .wercker file has been created which enables the link between the source code and wercker.
Step 3.
-------------
0 automatic supported target(s) found.
Step 4.
-------------
Triggering a new build.
done.
Done.
-------------
You are all set up to for using wercker. You can trigger new builds by
committing and pushing your latest changes.
Happy coding!
$ cat .wercker
[project]
id = some_project_id
- Wercker に登録されました
link
Wercker に登録済みならリンクする = .wercker を取得する。
# 対象プロジェクトはブラウザから Wercker に登録済みとする
$ ls -F .wercker
ls: cannot access .wercker: No such file or directory
$ wercker link
-----------------------
welcome to wercker-cli
-----------------------
Searching for git remote information...
Retrieving list of applications...
success: application is now linked to this repository
$ ls -F .wercker
.wercker
status
Wercker のビルド・デプロイ状況を確認する
# push によって wercker 起動
$ git push origin master
$ wercker status
-----------------------
welcome to wercker-cli
-----------------------
Retrieving builds from wercker...
Found 1 result(s)...
┌─────────┬──────────┬────────┬──────────┬───────────────────┬──────────────────┐
│ result │ progress │ branch │ hash │ created │ message │
├─────────┼──────────┼────────┼──────────┼───────────────────┼──────────────────┤
│ unknown │ 10.0% │ master │ 36ca32fa │ 11/18/14 05:48:59 │ test for wercker │
│ │ │ │ │ │ │
├─────────┼──────────┼────────┼──────────┼───────────────────┼──────────────────┤
# しばらく待機
# ビルド完了
$ wercker status
-----------------------
welcome to wercker-cli
-----------------------
Retrieving builds from wercker...
Found 1 result(s)...
┌────────┬──────────┬────────┬──────────┬───────────────────┬──────────────────┐
│ result │ progress │ branch │ hash │ created │ message │
├────────┼──────────┼────────┼──────────┼───────────────────┼──────────────────┤
│ passed │ 100.0% │ master │ 36ca32fa │ 11/18/14 05:48:59 │ test for wercker │
│ │ │ │ │ │ │
├────────┼──────────┼────────┼──────────┼───────────────────┼──────────────────┤
deploy
デプロイを実行する
$ wercker deploy
-----------------------
welcome to wercker-cli
-----------------------
Retrieving builds from wercker...
Found 2 result(s)...
┌───┬────────┬──────────┬────────┬──────────┬───────────────────┬────────────────┐
│ │ result │ progress │ branch │ hash │ created │ message │
├───┼────────┼──────────┼────────┼──────────┼───────────────────┼────────────────┤
│ 1 │ passed │ 100.0% │ master │ 47838e20 │ 11/18/14 00:52:33 │ Update gems │
├───┼────────┼──────────┼────────┼──────────┼───────────────────┼────────────────┤
│ 2 │ passed │ 100.0% │ master │ 99cd28e1 │ 11/17/14 08:07:06 │ remove gemfury │
├───┼────────┼──────────┼────────┼──────────┼───────────────────┼────────────────┤
Select which build to deploy(enter=1):
Retrieving list of deploy targets...
Found 1 result(s)...
┌───┬─────────────────┬────────┬───────────┬───────────────────┬────────┬──────────┬─────────────┐
│ │ target │ result │ deploy by │ deployed on │ branch │ commit │ message │
├───┼─────────────────┼────────┼───────────┼───────────────────┼────────┼──────────┼─────────────┤
│ 1 │ ruboty │ passed │ - │ 11/18/14 00:55:38 │ master │ 47838e20 │ Update gems │
├───┼─────────────────┼────────┼───────────┼───────────────────┼────────┼──────────┼─────────────┤
Select a target to deploy to(enter=1):
Success:
Build scheduled for deploy.
You can monitor the scheduled deploy in your browser using:
wercker targets deploy
Or query the queue for this application using:
wercker queue
builds
ビルド履歴を取得します
$ wercker builds
-----------------------
welcome to wercker-cli
-----------------------
Retrieving builds from wercker...
Found 3 result(s)...
┌─────────┬──────────┬────────┬──────────┬──────────────────────────┬──────────────────────┐
│ result │ progress │ branch │ hash │ created │ message │
├─────────┼──────────┼────────┼──────────┼──────────────────────────┼──────────────────────┤
│ aborted │ - │ master │ 9777a0b4 │ 2014-11-18T05:54:31.103Z │ not deploy [ci skip] │
│ │ │ │ │ │ │
├─────────┼──────────┼────────┼──────────┼──────────────────────────┼──────────────────────┤
│ passed │ 100.0% │ master │ 36ca32fa │ 11/18/14 05:48:59 │ test for wercker │
│ │ │ │ │ │ │
├─────────┼──────────┼────────┼──────────┼──────────────────────────┼──────────────────────┤
│ passed │ 100.0% │ master │ 66c01b91 │ 11/18/14 05:44:11 │ update .gitignore │
│ │ │ │ │ │ │
├─────────┼──────────┼────────┼──────────┼──────────────────────────┼──────────────────────┤
open
カレントプロジェクトの Wercker 画面をブラウザで開く
wercker open
-----------------------
welcome to wercker-cli
-----------------------
Opening link: https://app.wercker.com/#project/some_token
open targets
カレントプロジェクトの デプロイターゲットをブラウザで開く
$ wercker open targets
-----------------------
welcome to wercker-cli
-----------------------
Retrieving list of deploy targets...
Found 1 result(s)...
┌───┬─────────────────┬────────┬───────────┬───────────────────┬────────┬──────────┬──────────────┐
│ │ target │ result │ deploy by │ deployed on │ branch │ commit │ message │
├───┼─────────────────┼────────┼───────────┼───────────────────┼────────┼──────────┼──────────────┤
│ 1 │ ruboty │ passed │ - │ 11/18/14 06:21:56 │ master │ b6af9d9f │ wercker test │
├───┼─────────────────┼────────┼───────────┼───────────────────┼────────┼──────────┼──────────────┤
Select a target to deploy to(enter=1):
Opening link: https://app.wercker.com/deploytarget/some_token
queue
Wercker のキューを確認する。
ビルドとデプロイ双方を実行した状態で確認します。
$ wercker queue
-----------------------
welcome to wercker-cli
-----------------------
Retrieving list of unfinished builds.
Retrieving builds from wercker...
Found 1 result(s)...
┌─────────┬──────────┬────────┬──────────┬───────────────────┬──────────────┐
│ result │ progress │ branch │ hash │ created │ message │
├─────────┼──────────┼────────┼──────────┼───────────────────┼──────────────┤
│ unknown │ 5.0% │ master │ b6af9d9f │ 11/18/14 06:20:31 │ wercker test │
├─────────┼──────────┼────────┼──────────┼───────────────────┼──────────────┤
Retrieving list of deploy targets...
Found 1 scheduled deploys for ruboty
┌─────────┬──────────┬───────────┬───────────────────┐
│ result │ progress │ deploy by │ created │
├─────────┼──────────┼───────────┼───────────────────┤
│ unknown │ 5.0% │ xxxxx │ 11/18/14 06:20:49 │
├─────────┼──────────┼───────────┼───────────────────┤
No scheduled deploys found.
- ビルド・デプロイ完了後
$ wercker queue
-----------------------
welcome to wercker-cli
-----------------------
Retrieving list of unfinished builds.
Retrieving builds from wercker...
Found 0 result(s)...
┌────────┬──────────┬────────┬──────┬─────────┬─────────┐
│ result │ progress │ branch │ hash │ created │ message │
├────────┼──────────┼────────┼──────┼─────────┼─────────┤
├────────┼──────────┼────────┼──────┼─────────┼─────────┤
Retrieving list of deploy targets...
Found 0 scheduled deploys for ruboty
┌────────┬──────────┬───────────┬─────────┐
│ result │ progress │ deploy by │ created │
├────────┼──────────┼───────────┼─────────┤
├────────┼──────────┼───────────┼─────────┤
No scheduled deploys found.
apps
$ wercker apps
-----------------------
welcome to wercker-cli
-----------------------
Found 3 result(s)...
┌─────────────────┬──────────┬────────┬───────────┬─────────────────────────────────────────────┐
│ name │ author │ status │ followers │ url │
├─────────────────┼──────────┼────────┼───────────┼─────────────────────────────────────────────┤
│ ci_sample │ xxxxx │ passed │ 1 │ git@bitbucket.org:xxxxx/ci_sample.git │
│ gottani │ xxxxx │ passed │ 1 │ git@bitbucket.org:xxxxx/gottani.git │
│ ruboty │ xxxxxxx │ passed │ 1 │ git@github.com:xxxxxxx/ruboty.git │
├─────────────────┼──────────┼────────┼───────────┼─────────────────────────────────────────────┤
login
Wercker に login する。
GitHub 認証のみを利用している場合は、 ブラウザの Forgot your password? を利用して
パスワードを登録する必要がある。
$ wercker login
-----------------------
welcome to wercker-cli
-----------------------
username: xxxxx
password:
Warning: Login/password incorrect, please try again.
username: xxxxx
password:
Login successful. Welcome xxxxx!
logout
Wercker から logout する。
$ wercker logout
-----------------------
welcome to wercker-cli
-----------------------
About to clear the wercker settings for the current user on this machine
Are you sure you want to do this? [y/N] y
Success: wercker settings removed succesfully.
targets add
--
targets list
デプロイターゲットの一覧を表示
$ wercker targets list
-----------------------
welcome to wercker-cli
-----------------------
Retrieving list of deploy targets...
Found 1 result(s)...
┌─────────────────┬────────┬───────────┬───────────────────┬────────┬──────────┬──────────────┐
│ target │ result │ deploy by │ deployed on │ branch │ commit │ message │
├─────────────────┼────────┼───────────┼───────────────────┼────────┼──────────┼──────────────┤
│ ruboty │ passed │ - │ 11/18/14 06:21:56 │ master │ b6af9d9f │ wercker test │
├─────────────────┼────────┼───────────┼───────────────────┼────────┼──────────┼──────────────┤
targets details
デプロイターゲットの一覧を表示 + 指定したデプロイターゲットをブラウザで開く
$ wercker targets details
-----------------------
welcome to wercker-cli
-----------------------
Retrieving list of deploy targets...
Found 1 result(s)...
┌───┬─────────────────┬────────┬───────────┬───────────────────┬────────┬──────────┬──────────────┐
│ │ target │ result │ deploy by │ deployed on │ branch │ commit │ message │
├───┼─────────────────┼────────┼───────────┼───────────────────┼────────┼──────────┼──────────────┤
│ 1 │ ruboty │ passed │ - │ 11/18/14 06:21:56 │ master │ b6af9d9f │ wercker test │
├───┼─────────────────┼────────┼───────────┼───────────────────┼────────┼──────────┼──────────────┤
Select a target to deploy to(enter=1):
Opening link: https://app.wercker.com/deploytarget/some_token
update
wercker cli を update する