I’m Alex, The Product and Marketing guy here at Distelli. When I began working at Distelli 9 months ago, I quickly realized that it’s difficult to promote a deeply technical SaaS product (built by engineers, for engineers) without being an engineer myself.
So I did the only logical thing: I taught myself how to write code. While I’m not as proficient as Brian, Boris, or Michael on my team, I can hold my own when it comes to firing up Node apps, integrating with API’s, and shipping something valuable.
My latest application, Distelli-Slash, allows developers to do everything they can do within Distelli entirely from Slack using “slash commands”. Distelli-Slash is my first piece of customer-facing code and I’m happy to share it with you today. Here’s how it works:
You can list all your Distelli applications and environments: Applications are groupings centered around your GitHub or BitBucket repository. Environments are groupings of servers with similar configurations.
Create new applications or environments:
List the releases associated with your Distelli applications:
Releases are created upon the successful build of an application - usually after doing a
git push or
hg push of your repository
And deploy any release of your application:
I’ll be maintaining and updating this project and if you have additional features you’d like to see send me email or open a pull request.
##Setting Up Distelli-Slash
To view the full source for Distelli-Slash, you can check-out the public GitHub repository by right here.
If you’d rather just see what you’re capable of doing via Slack, click here.
###Before you Begin: Before you begin this tutorial, make sure you’ve created a Distelli account and forked the Distelli-Slash GitHub repository found here.
###Creating a Distelli Application:
Log into your Distelli account and create a new Distelli application by selecting the “New App” button on the top right of the screen:
1. Name your application “Distelli-Slash” and connect it to the GitHub repository you forked before starting this tutorial:
2. Connect the “master” branch, and select “All Done” when prompted if you’d like to create any additional environments:
3. Because a Distelli-Manifest.yml file is already included in your forked repository, in order to start the build, all you need to do is change the 1st line of your distelli-manifest.yml file to use your Distelli username:
4. Once you’re modified your distelli-manifest.yml file to use your own username, commit and push your changes:
We’ve just started our first build and configured auto-build so when you do a
git push in the future, your repository will automatically build. You’ll be automatically taken to the builds overview screen where we can inspect our first build:
On successful build, a release of your application is automatically created. But before we deploy this application, let’s make a couple other changes.
###Configuring your Secrets.js File Now we’ll need to configure our secrets.js file with our Distelli API token and Slack username.
Create a Distelli API token at https://www.distelli.com/username/settings?section=API
Select “Create API Token” and describe your token:
Open your secrets.js file, paste your Slack username, with your API token to the right like the example below: Add additional username’s and API tokens for each member of your team. By doing this, each team member will show as the deployer when they make a deployment via Slack. Commit and push your changes when you’re done.
###Adding a Server to the Distelli-Slash-Prod Environment Once you’ve configured and successfully built your app, you’ll need to deploy it to a server in order to make use of the Slack-Slash command.
- Navigate to the servers section of Distelli at wwww.distelli.com/username/servers. Replace username with your Distelli username.
- Select the “New Server” button on the top right of the screen:
- For this tutorial, we’re going to deploy to a DigitalOcean Droplet. Select “Add Existing Server”, you should see the following screen:
- Now you’ll need to SSH into your server and paste the agent install command listed on the screen. Your terminal should look similar to the following when you’re complete:
- Once you’ll installed the agent, go back to the browser and hit the “Install Complete” button. Then, select the server you just added:
- Select “distelli-slash-prod” to add your server to the Distelli-Slash Production environment you created early in this tutorial: Once you’ve selected “distelli-slash-prod” environment, hit the “Add Environments!” button.
###Deploying the Slack-Slash App Now that we’ve added a server to the distelli-slash-prod environment, we’re ready to deploy Distelli-Slash.
- Navigate back to the distelli-slash-prod environment page at https://www.distelli.com/username/envs/distelli-slash-prod. Replace username with your Distelli username:
- To deploy the latest release of your application, simply select the green rocket icon on the top right of the page:
- You’ll be shown an overview page where you can select stagger settings. As we are only deploying to a single server, stagger settings won’t be needed. Hit the green deploy button:
- You’ll be taken the deployment page where we can view real-time streaming application logs:
###Creating a Slack Slash Command 1. Navigate to https://your-team.slack.com/services/new/slash-commands. Replace your-team with your own team name. Enter /distelli as the command name and select “Add Slash Command Integration”: In the URL field, specify the IP address of the server you’re deploying Distelli-Slash with :3000 appended to the end to specify port 3000: After you’ve entered your Slack URL, save your Slack Token for use later and select the “Save Integration” button.
###Configuring Environment Variables We’ll need to configure some environment variables on the distelli-slash-prod environment. 1. Navigate to https://www.distelli.com/username/envs/distelli-slash-prod. Replace username with your Distelli username:
- Click to set environments variables on the right hand-side of the page. You’ll need to set three environment variables: USERNAME, SLACKTOKEN and SLACKTEAM. Your USERNAME should be set to your Distelli username, your SLACKTOKEN should be set to the token found in the previous step and your SLACKTEAM can be found by visiting https://api.slack.com/methods/team.info/test. It should look something like this when you’re done:
You’ve officially done setting up your Distelli Slash command, below is a full list of everything you can do:
/distelli List Apps: List all apps associated with your Distelli account. Use the command
List Apps After [AppName] to see the next page of results.
/distelli List Envs: List all envs associated with your Distelli account. Use the command
List Envs After [EnvName]to see the next page of results.
/distelli List Envs for [AppName]: List all envs associated with a Distelli app.
/distelli List Builds: List all builds associated with your Distelli account. Use the command
List Builds After [BuildNum]to see the next page of results.
/distelli List Servers: List all servers associated with your Distelli account. Use the command
List Servers After [ServerName]to see the next page of results.
/distelli List Servers for Env [EnvName]: List all servers associated with an app enviroment.
/distelli List Releases for App [AppName]: List all releases associated with an app.
/distelli Create App [App Name]: Create a Distelli application.
/distelli Create Env [Env Name] for app [AppName]: Create a Distelli environment.
/distelli Restart Env [Env Name]: Restart an existing environment.
/distelli Latest release for app [appName]: Get information on the latest release associated with an app.
/distelli Deploy latest to env [envName]: Deploy the latest release to an environment.
/distelli Deploy [vXX] to env [envName]: Deploy a specific releases to an environment.
Shoot me an email (alex at distelli.com) if you need a hand with setup!