Automate database changes using Jira and Bytebase.
jira
folder for this tutorialjira
demo appDatabase Change
issue filling the summary, SQL, database, and description fields, the status is Todo
.In Progress
.Done
, Jira issue status will be set to Done
.jira
demo app.jira
folder of the api-example
repository, and copy env-template.local
file as .env.local
. Replace the placeholders with yours.
pnpm i
and pnpm run dev
, you can run the demo app locally with localhost:xxxx
. However, the app need to listen to webhook from Jira and Bytebase, so you need to make the app network accessible from both. By using ngrok or vscode ports, you can achieve this.
/api/receive-jira-issue-webhook
to your base URL for the demo jira app, select Issue created and updated
, and click Create.
Service Account
as User Type, fill in the Email, give it Workspace DBA
role, and then click Create. Copy the API Token to the .env.local
file.
In Progress
/ Done
and set its Bytebase issue link.env.local
file.
Database Change
issue, fill in the fields summary, SQL, database, and description, and click Create. Here’s the screenshot of the issue.
jira
app demo, you will see there’s a jira webhook received with Todo
status.
src/api/receive-jira-issue-webhook/route.ts
.
Database Change
. and then if the webhook event is issue_created
.
project key
and Bytebase’s project name
with the ones you configured in the .env.local
. then it will try to match the Jira’s database
with the database belonging to that Bytebase project.
In Progress
In Progress
with Bytebase url link filled.
jira
app demo, it’s updated, too.
src/api/receive-jira-issue-webhook/route.ts
.
Todo
to In Progress
.
/rest/api/3/issue/${issueKey}
to update Bytebase Link/rest/api/3/issue/${issueKey}/transitions
to change the statusDone
, Jira API will set Jira issue status as Done
.jira
app demo.
Done
.
src/app/api/poll-bytebase-issue/route.ts
. Bytebase will poll the issue status every 3 seconds, if it’s a issue update, it will parse the Jira issue key from the Bytebase issue name, and then call the Jira API to update the issue status to Done
.