YouTrack および Hub ヘルプの開発者ポータル

忘れられた愛着

このワークフローでは、説明またはコメントに添付ファイルが含まれている場合、その課題に添付ファイルを追加するようにユーザーに通知します。

名前

@jetbrains/youtrack-workflow-forgotten-attachment

自動添付

いいえ

モジュール

添付ファイルを参照するために説明を確認する (変更時のルール)

添付ファイルを参照するためにコメントを確認する (変更時のルール)

attach-file-utils.js (カスタムスクリプト)

ユースケース

このワークフローは、説明やコメントで添付ファイルを参照するときに、ユーザーがそのファイルを課題に添付していることを確認できます。

モジュール

このワークフローには、プロジェクトのルールとしてアタッチできる 2 つのモジュールと、カスタムスクリプトを含む 3 つ目のモジュールが含まれています。このスクリプトには、両方の規則で使用される共通の機能が含まれています。

添付ファイルを参照するために説明を確認する

最初のモジュールには、添付ファイルへの参照について説明をスキャンする規則が含まれています。参照が見つかった場合、ユーザーはファイルを課題に添付するように通知されます。

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const utils = require('./attach-file-utils'); exports.rule = entities.Issue.onChange({ title: 'Check description for reference to attachment', guard: (ctx) => { return ctx.issue.becomesReported || ctx.issue.isChanged('description'); // optimize blob (description) read }, action: (ctx) => { const issue = ctx.issue; const description = issue.description; if (!description) { return; } if (issue.becomesReported && ctx.issue.attachments.isEmpty()) { utils.findAndShowMessage(description); return; } if (issue.isChanged('description')) { const oldDescription = issue.oldValue('description') || ''; let found = ''; if (utils.words().some(function (word) { if ((description.indexOf(word) > -1) && (oldDescription.indexOf(word) === -1)) { found = word; return true; } return false; })) { utils.showMessage(found); } } } });

添付ファイルを参照するためにコメントを確認する

2 番目のモジュールには、添付ファイルへの参照について新しいコメントをスキャンする規則が含まれています。参照が見つかった場合、ユーザーはファイルを課題に添付するように通知されます。

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const utils = require('./attach-file-utils'); exports.rule = entities.Issue.onChange({ title: 'Check comment for reference to attachment', guard: (ctx) => { return !ctx.issue.comments.added.isEmpty(); }, action: (ctx) => { ctx.issue.comments.added.forEach(function (comment) { if (comment.attachments.isEmpty()) { utils.findAndShowMessage(comment.text); } }); } });

attach-file-utils.js

最後のモジュールには、説明またはコメントに添付ファイルへの参照が含まれているかどうかを判断するために両方のルールが使用するコードが含まれています。このスクリプトには、メッセージをユーザーに表示するコードも含まれています。

const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); exports.words = function () { return 'attachments, attachment, attached, attaches, attach, attaching'.split(', '); }; exports.showMessage = function (what) { workflow.message('You have mentioned the "{0}" word, don\'t forget to attach it (them).', what); }; exports.findAndShowMessage = function (text) { let found = ''; if (exports.words().some(function (word) { if (text.indexOf(word) > -1) { found = word; return true; } return false; })) { exports.showMessage(found); } };
2025 年 11 月 21 日