JobTomate is a Ruby application used by JobTeaser's Tech Team to automate some parts of its workflows.
It's currently connected to the following external applications:
- Github (webhook trigger)
- Jira (webhook trigger and API commands)
- Slack (webhook trigger and API commands)
- Google Sheets API (synchronization script)
We chose to keep this repository public for a few reasons:
- The concept of such an application to automate some parts of the process and the boilerplate this project provides may be useful to other teams.
- Some parts of the code may be reused in other projects.
- This may interest developers, hopefully possible hires, that want to look into our team's internal processes and tooling. (If that matches you, have a look to our open positions.)
Consequently, this project has not been designed to be reusable by external persons. Deploying is not 1-click away and some parts of the documentation may be oriented towards members of the JobTeaser Tech Team.
Once deployed, if it's correctly configured, there is nothing to "use" really. JobTomate will simply perform the workflows it is supposed to!
JobTomate use its Mongo database to store some of its configuration (for example tokens, users...). To update this configuration you can:
- Connect to a Ruby console and add the appropriate model records manually
- Use the
script/sync_config_from_google_sheets.rb
script which provides synchronization with a Google Sheets document (see Deployment and configuration > Google Sheets API).
To JobTeaser Tech Team: the Google Sheets synchronization has been setup, find more information about this on this Confluence page.
Accessing the logs will depend on your deployment.
To JobTeaser Tech Team: more information about this on this Confluence page.
NB: only contribution from JobTeaser Tech Team will be accepted on this repository. You may fork it if you want to do your own modifications. However, please feel free to notify us of interesting updates that we may merge into our fork.
To JobTeaser Tech Team: more information on this Confluence page.
- Read the documentation:
- Ask help to the past contributors
After cloning the repository...
We assume you know how to do this. Or you know how to Google it. Or how to ask someone near.
NB: you need Docker installed and running for this
docker-compose up -d mongo-dev mongo-test
Copy .env.example
to .env
and make the necessary changes.
JIRA_API_URL_PREFIX=https://<REPLACE-ME>.atlassian.net/rest/api/2
JIRA_BROWSER_ISSUE_PREFIX=https://<REPLACE-ME>.atlassian.net/browse
Replace <REPLACE-ME
with the prefix of your Atlassian domain.
NB: by default in non-production environments (see RACK_ENV
environment variable), the JIRA_DRY_RUN
is set to "true"
to prevent JIRA API calls with effects (e.g. update, delete).
rake test
JIRA_USERNAME=<REPLACE-ME>
JIRA_PASSWORD=<REPLACE-ME>
You need to have an user authorized to perform API calls on Jira. You can use your own personal credentials, as long as you keep them secret and stored on your workstation. DO NOT USE THEM TO CONFIGURE A PRODUCTION APPLICATION.
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/REPLACE-ME
SLACK_API_TOKEN=<REPLACE-ME>
Check your Slack instance details to feed this information.
GOOGLE_AUTH_ID=<REPLACE-ME>
GOOGLE_AUTH_SECRET=<REPLACE-ME>
GOOGLE_SHEETS_CONFIGURATION_ID=<REPLACE-ME>
These are only needed if you want to run the application's configuration synchronization with Google Sheets script (script/sync_config_from_google_sheets.rb
). If you don't need this, leave it unchanged. Otherwise, check the [Google Sheets API](#Google Sheets API) section below.
To JobTeaser Tech Team members: you can find more information to help you with the setup in this Confluence page.
bin/console
NB: by default in non-production environments (see RACK_ENV
environment variable), the JIRA_DRY_RUN
is set to "true"
to prevent JIRA API calls with effects (e.g. update, delete).
docker-compose run mongo-client
Some scripts are available in the project if you deployed to Heroku, easing some tasks like deploying or copying the staging or production databases to your local environment.
NB: you must have the mongo
command-line client tool installed on your local machine
bin/dump_production_to_local
bin/dump_production_to_staging
bin/set_env_staging
bin/set_env_production
bin/deploy_staging
bin/deploy_production
heroku run bin/console -a <APP-NAME>
heroku run ruby db/migrate/... -a <APP-NAME>
The deployed code will run a web application that will handle webhooks (see triggers/webhooks.rb
).
Scheduled tasks must be setup for tasks triggers (triggers/tasks
). If you deploy on Heroku, you can use Heroku's Scheduler plugin.
No task to be setup. If needed, you should add the following command: bin/run_task fetch_toggl_reports
Some maintenance scripts must be scheduled too:
script/cleanup_stored_webhooks_and_requests
: every day
You must setup a webhook on JIRA to trigger JIRA-related workflows. You can find this in Administration > System > Webhooks.
Here is the configuration to use:
- URL:
https://<your-domain>/webhooks/jira
- Select "updated" issue events, on all issues (no filter)
For each repository that needs to be connected to JobTomate, setup the webhook like this:
- URL:
https://<your-domain>/webhooks/github
- Content type: select "application/json"
- Select "Send me everything"
Setup a webhook integration on Slack. Any default will do since they are all overriden by JobTomate. The webhook URL must be defined in the environment variables (SLACK_WEBHOOK_URL
).
The script/sync_config_from_google_sheets.rb
script may be used to synchronize the application's configuration stored in the Mongo database using a Google Sheets document. This makes updating the configuration easier for non-developers and for sharing the permission to update the configuration without having to give production access permission.
To enable this integration, you need to perform the following.
Setup a Google Developers Console Project
You can follow the instructions available on Google Sheets API Ruby Quickstart.
Write your Client ID and Client Secret somewhere secure.
Create the configuration Google Sheets document
The document must follow this structure:
- A page named after a model, e.g.
User
forJobTomate::Data::User
. - One column per model field, e.g.
github_user
. - A single row at the top with the field's name.
Share the document with the appropriate users. You will need a "technical" user with limited permissions to be able to access this file for deployment. You should use this user to retrieve API tokens for your production instance.
Retrieve tokens
The first time you'll use the script, it will ask you to perform an OAuth authentication to retrieve API tokens.
NB: SECURITY WARNING
While you can perform the OAuth authentication using your personal jobteaser.com Google account for development purposes, you MUST NOT use it to deploy the application.
This token could indeed be used to access all your Google Sheets documents. It should remain secured on your workstation.
Update .env
GOOGLE_AUTH_ID=
GOOGLE_AUTH_SECRET=
GOOGLE_SHEETS_CONFIGURATION_ID=
- Insert the retrieved client ID and client secret.
- Insert the document's ID (the string after
spreadsheets/d/
in the URL).
Reset your token
If you need to reset your token (e.g. if you changed the user authorized to access the file), connect to the application's console and drop the JobTomate::Data::Token
stored in the DB.