Search code examples
continuous-deploymentphabricator

Configure a local build plan with Harbormaster and Drydock


I'm trying to create a simple build plan using Harbormaster and Drydock:

  1. Whenever a commit is made the build plan Deployment should be triggered. This can be easily done with Harold.

  2. The build plan Deployment has some build steps which run a command.

I know Drydock and Harbormaster are prototypes so it seems there is no much documentation.

So first I've created a build plan and added two build steps for testing:

  • Lease Host build step with localhost as name and linux as platform
  • Run Command build step with php /var/www/ci/test.php as command and localhost as host

But the error message after a manual start was:

exception 'Exception' with message 'Lease has been broken!' in /var/www/phabricator/src/applications/drydock/storage/DrydockLease.php:172
Stack trace:
#0 /var/www/phabricator/src/applications/drydock/storage/DrydockLease.php(198): DrydockLease::waitForLeases(Array)
#1 /var/www/phabricator/src/applications/harbormaster/step/HarbormasterLeaseHostBuildStepImplementation.php(32): DrydockLease->waitUntilActive()
#2 /var/www/phabricator/src/applications/harbormaster/worker/HarbormasterTargetWorker.php(52): HarbormasterLeaseHostBuildStepImplementation->execute(Object(HarbormasterBuild), Object(HarbormasterBuildTarget))
#3 /var/www/phabricator/src/infrastructure/daemon/workers/PhabricatorWorker.php(91): HarbormasterTargetWorker->doWork()
#4 /var/www/phabricator/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php(162): PhabricatorWorker->executeTask()
#5 /var/www/phabricator/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php(22): PhabricatorWorkerActiveTask->executeTask()
#6 /var/www/libphutil/src/daemon/PhutilDaemon.php(183): PhabricatorTaskmasterDaemon->run()
#7 /var/www/libphutil/scripts/daemon/exec/exec_daemon.php(125): PhutilDaemon->execute()
#8 {main}

Could anybody give me some hints how to run commands on localhost with Harbormaster and Drydock?


Solution

  • The problem was that I have not created any resource through Drydock. Here how you can get execute a command with Harbormaster and Drydock:

    1. Create a Drydock Blueprint (e.g. Blueprint 4711).
    2. Create a Passphrase SSH Private Key for Drydock which can be used to access your local host through SSH (e.g. K123).
    3. Create a Drydock Resource through the CLI for your local host:

      ./bin/drydock create-resource --blueprint 4711 --name localhost --attributes host=localhost,platform=linux,remote=true,port=22,path=/var/drydock,credential=123
      
    4. Create a Harbormaster Build Plan.

    5. Add a Build Step (Lease Host) to your Build Plan, use your Drydock Blueprint as Artifact and linux as Platform.
    6. Add a second Build Step to your Build Plan (Run Command) with the command you want and your Drydock Blueprint as Host.

    Using the server itself for CD/CI might be only an option for small installations.