Skip to content

Commit e60d4f4

Browse files
authored
Allow the bot to work with Jira Cloud (#303)
* Allow the bot to work with Jira Cloud * Minor workflow updates * no matrix
1 parent b2bfd4f commit e60d4f4

File tree

8 files changed

+21
-14
lines changed

8 files changed

+21
-14
lines changed

.github/workflows/pull-request-build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
node-version: [18.19.1]
14+
node-version: [18.x]
1515

1616
steps:
1717
- name: Checkout repository
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919

2020
- name: Set up Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424

2525
- name: Set up cache for NPM modules
26-
uses: actions/cache@v3
26+
uses: actions/cache@v4
2727
with:
2828
path: ~/.npm
2929
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

.github/workflows/push-build-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Set up Node.js ${{ matrix.node-version }}
26-
uses: actions/setup-node@v3
26+
uses: actions/setup-node@v4
2727
with:
2828
node-version: ${{ matrix.node-version }}
2929

3030
- name: Set up cache for NPM modules
31-
uses: actions/cache@v3
31+
uses: actions/cache@v4
3232
with:
3333
path: ~/.npm
3434
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node_modules
44
.vscode/*
55
.history
66
**/.DS_Store
7+
.idea/
78

89
**/*.log
910
settings.json

config/local.template.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 1. Copy this file
22
# 2. Rename the copy to `local.yml`
3-
# 3. Change the bot token, and your Jira personal access token if desired, and save the file
3+
# 3. Change the bot token, and your Jira email+personal access token if desired, and save the file
44
#
55
# You can add more configs if you want to.
66
#
@@ -11,4 +11,5 @@
1111
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212

1313
token: <your bot token>
14+
jiraUser: <your jira email>
1415
jiraPat: <your personal access token>

config/template.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ logDirectory: <string | false>
1111
# Your bot token used to log in to Discord with the bot.
1212
token: <string>
1313

14-
# Your Jira personal access token.
14+
# Your Jira E-Mail and personal access token.
1515
# Optional; if not assigned a value, the bot will not attempt to log into Jira.
16+
jiraUser: <string>
1617
jiraPat: <string>
1718

1819
# A list of user IDs for owner only commands.

src/BotConfig.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export default class BotConfig {
116116

117117
private static token: string;
118118
private static jiraPat?: string;
119+
private static jiraUser?: string;
119120

120121
public static owners: Snowflake[];
121122

@@ -149,6 +150,7 @@ export default class BotConfig {
149150
this.logDirectory = getOrDefault( 'logDirectory', false );
150151

151152
this.token = config.get( 'token' );
153+
this.jiraUser = getOrDefault( 'jiraUser', undefined );
152154
this.jiraPat = getOrDefault( 'jiraPat', undefined );
153155

154156
this.owners = getOrDefault( 'owners', [] );
@@ -194,10 +196,12 @@ export default class BotConfig {
194196
public static jiraLogin(): void {
195197
// TODO: integrate newErrorHandling from Jira.js
196198
MojiraBot.jira = new JiraClient( {
197-
host: 'https://bugs.mojang.com',
198-
telemetry: false,
199-
authentication: this.jiraPat === undefined ? undefined : {
200-
personalAccessToken: this.jiraPat,
199+
host: 'https://mojira.atlassian.net',
200+
authentication: this.jiraPat === undefined || this.jiraUser === undefined ? undefined : {
201+
basic: {
202+
email: this.jiraUser,
203+
apiToken: this.jiraPat,
204+
},
201205
},
202206
} );
203207
}

src/commands/SearchCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class SearchCommand extends SlashCommand {
2121

2222
try {
2323
const embed = new EmbedBuilder();
24-
const searchFilter = `text ~ "${ plainArgs }" AND project in (${ BotConfig.projects.join( ', ' ) })`;
24+
const searchFilter = `(description ~ "${ plainArgs }" OR summary ~ "${ plainArgs }") AND project in (${ BotConfig.projects.join( ', ' ) })`;
2525
const searchResults = await MojiraBot.jira.issueSearch.searchForIssuesUsingJql( {
2626
jql: searchFilter,
2727
maxResults: BotConfig.maxSearchResults,

src/tasks/VersionFeedTask.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface JiraVersion {
1313
archived: boolean;
1414
released: boolean;
1515
releaseDate?: string;
16-
projectId: number;
16+
projectId: number | string;
1717
}
1818

1919
function versionConv( version: Version ): JiraVersion | undefined {

0 commit comments

Comments
 (0)