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

ワークフローで課題の可視性を制限する

YouTrack の許可スキームを使用して、YouTrack の課題への読み取りアクセスを制限できます。プロジェクトで課題の作成権限を持っているが読み取り課題権限を持たないユーザーは、自分で作成した課題のみを見ることができます。ただし、このセットアップは非常にバイナリです。ユーザーは、自分で報告した課題のみを読んで更新するか、プロジェクト内のすべての課題にアクセスできます。実際には、状況は通常はるかに複雑です。作成した課題だけでなく、何らかの方法で共有されている課題も含めて、一部の人々にいくつかの課題を読んで更新してもらいたい場合はどうなりますか?

このユースケースをサポートするには、報告者に読み取り課題権限を付与し、ワークフローを使用して、他の報告者を除外するグループに課題の可視性を自動的に制限します。次のワークフロールールは、課題が報告されるとすぐに課題の可視性を制限します。

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); exports.rule = entities.Issue.onChange({ title: 'Set "Visible to" group on submit', guard: (ctx) => { return ctx.issue.becomesReported; }, action: (ctx) => { ctx.issue.permittedGroups.add(ctx.viewers); workflow.message('Users from group "' + ctx.viewers.name + '" can see this request.'); }, requirements: { viewers: { type: entities.UserGroup } } });

各課題は、その報告者と Viewers グループのすべてのメンバーに表示されます。ただし、報告者または Viewers グループのメンバーは、プロジェクトで読み取り課題権限を持つ他のユーザーと課題を「共有」できます。課題を共有するには、ユーザーは表示対象リストから別のユーザーを選択します。

ワークフローを使用して可視性を管理できる方法は他にもたくさんあります。スキーム全体の柔軟性を高めるために、次のルールを 1 つ以上追加することを検討してください。

メンションされたユーザーを追加する

このルールは、ユーザーが @mentionedin コメントである場合、ユーザーを表示対象リストに自動的に追加します。

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); const loginRegex = /@(([A-Z0-9._@$+\-=|])*)/gi; exports.rule = entities.Issue.onChange({ title: 'Automatically add users to the "visible to" list', guard: (ctx) => { const issue = ctx.issue; return issue.comments.added.isNotEmpty() && (issue.permittedGroups.isNotEmpty() || issue.permittedUsers.isNotEmpty()); }, action: (ctx) => { const issue = ctx.issue; let text = ''; issue.comments.added.forEach(function (comment) { text += comment.text + '\n'; }); let message = ''; const matches = text.match(loginRegex); if (matches) { matches.forEach(function (m) { const login = m.slice(1); if (login) { const user = entities.User.findByLogin(login); if (user) { issue.permittedUsers.add(user); message += 'User "' + user.fullName + '" is added to issue readers. '; } else { message += 'User with login "' + login + '" not found. '; } } }); } if (message) { workflow.message(message); } }, requirements: {} });

可視性設定の更新をブロックする

このルールは、報告された課題の表示対象設定への変更をブロックします。これにより、機密データを含む課題の可視性設定の不要な変更が防止されます。

// This rule assumes that issue visibility is set to a specific group // at the moment when an issue becomes reported. // Each project has its own visibility group. const entities = require('@jetbrains/youtrack-scripting-api/entities'); const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); exports.rule = entities.Issue.onChange({ title: 'Block changes to visibility group for reported issues', guard: (ctx) => { const issue = ctx.issue; return issue.isReported && !issue.becomesReported && issue.isChanged('permittedGroups'); }, action: (ctx) => { workflow.check(false, 'You cannot change group visibility restrictions for reported issues. ' + 'Instead, you can add single users to the "visible to" list.'); }, requirements: {} });

ユーザーが他のユーザーを削除できないようにする

このルールは、ユーザーが表示対象リストから他のユーザーを削除できないようにします。

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); exports.rule = entities.Issue.onChange({ title: 'Do not remove users from "visible to" list', guard: (ctx) => { const issue = ctx.issue; return issue.permittedUsers.removed.isNotEmpty(); }, action: (ctx) => { workflow.check(false, 'You cannot remove other users from the "visible to" list.'); }, requirements: {} });

割り当ての可視性を更新

このルールは、ユーザータイプ (承認者や検証者など) を格納するカスタムフィールドでユーザーが選択されたときに、表示対象リストにユーザーを自動的に追加します。

また、このルールの修正版を使用して、プロジェクトチームの他のメンバーからデリケートな課題を隠すこともできます。例: あなたの会社は、会計士が他の会計士によって処理される支払い要求を見ることを望まない。ここで、ユーザーが割り当て対象として設定されている場合、表示対象リストにユーザーを追加できます。

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); exports.rule = entities.Issue.onChange({ title: 'Add Authorizer to the "visible to" list', guard: (ctx) => { const fs = ctx.issue.fields; return fs.isChanged(ctx.AuthBy) && fs.AuthBy; }, action: (ctx) => { const issue = ctx.issue; issue.permittedUsers.add(issue.fields.AuthBy); workflow.message('The issue is now visible to ' + issue.fields.AuthBy.fullName); }, requirements: { AuthBy: { type: entities.User.fieldType, name: 'Authorizer' } } });
2025 年 11 月 21 日

関連ページ:

ワークフローのユースケース

課題トラッカーがすべての内部プロセスをサポートしていると想像してください。複雑な設定を掘り下げる必要はありません。独自のルールを定義するだけで、課題トラッカーはそれらを正確に追跡します。ルールは、割り当ての自動化、時間の管理、ポリシーの実装、レポートの生成、通知の送信、課題のエスカレーションを行います。また、プロジェクト間の依存関係も維持し、作業を行うことを決して忘れません。これが、YouTrack ワークフローができることです。ワークフローは、一度だけ定義されるプロセスではなく、いつでも変更で...

不要な更新を防ぐ

特定のユーザーがカスタムフィールドの値を表示または変更できないようにするには、フィールドをプライベートにするオプションがあります。ただし、このソリューションにはいくつかの制限があります。ユーザーは、プロジェクト内のすべてのプライベートカスタムフィールドを読み取ったり更新したりできますが、いずれも更新できません。ワークフローを使用すると、パブリックフィールドの変更に対する不要な更新を防ぐことができます。さまざまな更新制限をサポートできます。例: 報告されたバグの状態を Fixed から Verifi...