<p>Screwdriver.cd offers powerful features such as <a href="https://docs.screwdriver.cd/user-guide/templates">templates</a>, <a href="https://docs.screwdriver.cd/user-guide/commands">commands</a>, <a href="https://docs.screwdriver.cd/user-guide/configuration/secrets">secrets</a>, and <a href="https://docs.screwdriver.cd/user-guide/metadata">metadata</a>, which can be used to simplify build settings or as build parameters. However, it’s difficult to reproduce equivalent features for local builds.</p>
<p>Although you can use these features by uploading your changes to an SCM such as GitHub, you may feel like it is a pain to upload your changes over and over in order to get a successful build. With sd-local, you can easily make sure the build is not corrupted before uploading changes to SCM and debug the build locally if it fails.</p>
<p>Note:<br/><em>Because sd-local works with Screwdriver.cd, it does not work by itself. If you don’t have a Screwdriver.cd cluster, you need to set up it first.</em></p>
<p>See the documentation at <a href="https://docs.screwdriver.cd/cluster-management/">https://docs.screwdriver.cd/cluster-management/</a>.</p>
<h2>How to Install</h2>
<p>sd-local uses Docker internally, so make sure you have Docker Engine installed locally.</p>
<p><a href="https://www.docker.com/">https://www.docker.com/</a></p>
<p>The next step is to install sd-local. Download the latest version of sd-local from the GitHub release page below and grant execute permission to it.</p>
<p><a href="https://github.com/screwdriver-cd/sd-local/releases">https://github.com/screwdriver-cd/sd-local/releases</a></p>
<pre><code>$ mv sd-local_*_amd64 /usr/local/bin/sd-local$ chmod +x /usr/local/bin/sd-local
</code></pre>
<h2>Build configuration</h2>
<p>Configure to use the templates and commands registered in your Screwdriver.cd cluster from sd-local. sd-local communicates with the following SD components:</p>
<ul><li>API
<ul><li>Validating screwdriver.yaml</li>
<li>Getting a template</li>
</ul></li>
<li>Store
<ul><li>Getting a command</li>
</ul></li>
</ul><pre><code>$ sd-local config set api-url https://<your-api-server> # e.g. <a href="https://api.screwdriver.cd">https://api.screwdriver.cd</a>
$ sd-local config set store-url https://<your-store-server> # e.g. <a href="https://store.screwdriver.cd">https://store.screwdriver.cd</a>
</code></pre>
<p>Set the API token for the above component to authenticate.
Please refer <a href="https://docs.screwdriver.cd/user-guide/api#authentication-and-authorization">the guide</a> how to get an API token.</p>
<pre><code>$ sd-local config set token <your API Token>
</code></pre>
<h2>Execute build</h2>
<p>Please create the following screwdriver.yaml in the current directory.</p>
<pre><code>jobs:
main:
image: node:12
steps:
- hello: echo -n "Hello, world!"
</code></pre>
<p>Run the build with the following command specifying the job name.
Note: <em>Builds can only be run at a job level.</em></p>
<pre><code>$ sd-local build main
INFO [0000] Prepare to start build...
INFO [0017] Pulling docker image from node:12...
sd-setup-launcher: Screwdriver Launcher information
sd-setup-launcher: Version: v6.0.70
sd-setup-launcher: Pipeline: #0
sd-setup-launcher: Job: main
sd-setup-launcher: Build: #0
sd-setup-launcher: Workspace Dir: /sd/workspace
sd-setup-launcher: Checkout Dir: /sd/workspace/src/screwdriver.cd/sd-local/local-build
sd-setup-launcher: Source Dir: /sd/workspace/src/screwdriver.cd/sd-local/local-build
sd-setup-launcher: Artifacts Dir: /sd/workspace/artifacts
sd-setup-launcher: set -e && export PATH=$PATH:/opt/sd && finish() { EXITCODE=$?; tmpfile=/tmp/env_tmp; exportfile=/tmp/env_export; export -p | grep -vi "PS1=" > $tmpfile && mv $tmpfile $exportfile; echo $SD_STEP_ID $EXITCODE; } && trap finish EXIT;
sd-setup-launcher: echo ;
hello: $ echo -n Hello, world!
hello:
hello: Hello, world!
</code></pre>
<p>See the <a href="https://docs.screwdriver.cd/user-guide/local">User Guide</a> for more details about the commands.</p>
<h2>Design Document</h2>
<p>For more details, check out our <a href="https://github.com/screwdriver-cd/screwdriver/blob/master/design/sd-local.md">design spec</a>.</p>
<h2>Compatibility List</h2>
<p>In order to use this feature, you will need these minimum versions:</p>
<ul><li>sd-local - v1.0.1</li>
<li>launcher - v6.0.70</li>
</ul><h2>Contributors</h2>
<p>Thanks to the following contributors for making this feature possible:</p>
<ul><li><a href="https://github.com/sugarnaoming">sugarnaoming</a></li>
<li><a href="https://github.com/s-yoshika">s-yoshika</a></li>
<li><a href="https://github.com/kkisic">kkisic</a></li>
<li><a href="https://github.com/MysticDoll">MysticDoll</a></li>
<li><a href="https://github.com/yuichi10">yuichi10</a></li>
<li><a href="https://github.com/kkokufud">kkokufud</a></li>
<li><a href="https://github.com/wahapo">wahapo</a></li>
<li><a href="https://github.com/tk3fftk">tk3fftk</a></li>
<li><a href="https://github.com/sakka2">sakka2</a></li>
<li><a href="https://github.com/cappyzawa">cappyzawa</a></li>
<li><a href="https://github.com/kumada626">kumada626</a></li>
</ul><h2>Questions and Suggestions</h2>
<p>We’d love to hear from you. If you have any questions, please feel free to reach out <a href="https://docs.screwdriver.cd/about/support">here</a>. You can also visit us on <a href="https://github.com/screwdriver-cd">Github</a> and <a href="https://slack.screwdriver.cd">Slack</a>.</p>