A bot for a tighter integration of GitHub into Jira and vice versa.
To link Jira tickets and GitHub pull request with one another, we at Liefery use Tickety-Tick. The format for title on GitHub is: [#${Jira ticket key}] ${Jira ticket summary}
The bot does two things:
QA: the bot does the following:QA: as a comment to the associated Jira ticket. The magic QA keyword can be configured.First you need a place for the bot to run. We at Liefery use Jenkins for this.
PipelineGit for Source Code Management:
[email protected]:liefery/github-jira-bot.git*/productionTrigger builds remotely (e.g., from scripts) for Build Triggers:
Authentication Token. Remember your token as you'll need it later when adding the bot to repositories on GitHub.Generic Webhook Trigger for Build Triggers:
Post content parameters (choose JSONPath as expression format):
REPO => $.repository.full_nameACTION => $.actionPR_NUMBER => $.pull_request.numberPR_TITLE => $.pull_request.titlePR_AUTHOR => $.pull_request.user.loginPR_DESC => $.pull_request.bodyCOMMENT_AUTHOR => $.comment.user.loginCOMMENT_BODY => $.comment.bodyCOMMENT_ID => $.comment.idISSUE_TITLE => $.issue.titleISSUE_NUMBER => $.issue.numberPrint post contentPrint contributed variablesPipeline script from SCM build step for Build:
Note: PR_TITLE and PR_NUMBER will be set in different ways depending on the webhook used to trigger the bot.
In a GitHub repository navigate to settings/webhooks and add a new webhook using the following configuration:
https:/JENKINS_URL/generic-webhook-trigger/invoke?token=XXX (use the same token as configured in the Authentication Token setting of the Jenkins build it should trigger)application/jsonLet me select individual events
Issue commentsPull requestsPushesIt is recommended that you don't use your personal GitHub and Jira accounts for the bot.
You can create accounts on GitHub and Jira with permission to access and contribute to the repositories/projects you want to use the bot for.
Here is a sample configuration:
export JIRA_USER = "XXX"
export JIRA_PASSWORD = "XXX"
export JIRA_URL = "https://XXX.atlassian.net"
export JIRA_PROJECT_KEY = "XXX"
export JIRA_ISSUE_TYPE = "Story"
export JIRA_FIX_VERSION_ID = "XXX"
export JIRA_SPRINT_FIELD = "customfield_XXX"
export JIRA_NEW_TICKET_TRANSITION_ID = 711
export GITHUB_USERNAME = "XXX"
export GITHUB_PASSWORD = "XXX"
export MAGIC_QA_KEYWORD = "QA:"
export MAX_DESCRIPTION_CHARS = 600
export COMPONENT_MAP = '{"repo":"component"}'
bundle install
ruby lib/run.rb
JIRA_USER: Username of a Jira account.JIRA_PASSWORD: Password of a Jira account.JIRA_URL: URL of your Jira workspace.JIRA_PROJECT_KEY: Key of a Jira project. This looks something like BT.JIRA_ISSUE_TYPE: Can be Story, Improvement or similar. This will only be used if the bot creates tickets.JIRA_FIX_VERSION_ID: Id of the fix version to use when creating a Jira ticket.JIRA_SPRINT_FIELD: The identifier of the sprint new tickets should be attached to upon creation.JIRA_NEW_TICKET_TRANSITION_ID: The database ID of the transition to the state where newly created Jira tickets should be moved to.GITHUB_USERNAME: Username of a GitHub account.GITHUB_PASSWORD: Password of a GitHub account.MAGIC_QA_KEYWORD: Keyword that detects information in comments that should be added to the Jira ticket.MAX_DESCRIPTION_CHARS: The maximum number of chars of a Jira ticket description that will be added to a pull request on GitHub. Omit this environment variable if you want to add the entire ticket description to GitHub.COMPONENT_MAP: Mapping of GitHub repositories and Jira components used when creating new Jira tickets. Has to be a stringified JSON hash..env.sample to .env..env and setup accounts.ruby lib/run.rb.This project uses RSpec for testing:
bundle installbundle exec rspecgit fetch
git checkout production
git pull
git reset --hard origin/master
git push
Content type
Image
Digest
Size
79.7 MB
Last updated
over 6 years ago
docker pull bensmithdeveloper/github-jira-bot