LogoLogo
HomeAbout usSign up
  • Introduction
  • AttentionSet
    • AttentionSet Best Practices
    • How to View AttentionSet for Others
    • How to Manually Change Attention
    • AttentionSet Chrome extension
    • Attention reasons
    • AttentionSet Slack Home Page
  • Releases
    • Getting Started with Releases
    • Concepts for Releases
      • Terminology for Releases
      • Two-step delivery
      • Rollbacks
      • Cherry-picks
      • Dogfood, Canary and Rollout
      • Release notes
    • How-to Guides for Releases
      • How to Create a Release Project
      • How to Configure Environments
      • How to Create a Scheduled Release
      • Create Custom Workflow Parameters
      • How to Manage Cherry-Picks
      • How to Resolve a Cherry-Pick Failure
      • Working with your CI / CD
        • GitHub Actions workflow
        • Buildkite workflow
    • API Reference for Releases
  • FlexReview
    • Getting Started with FlexReview
    • How to Onboard a Large Org
    • Concepts for FlexReview
      • Read-Only Mode in FlexReview
      • Recursive Ownership in FlexReview
      • Reviewer suggestion and assignment
      • FlexReview Teams and SLO Management
      • Validation in FlexReview
    • How-to Guides for FlexReview
      • How to Get a Reviewer Suggestion
      • How to Exclude Reviewers
      • How to Set Up Team Rules
      • Whitelist Teams for Review Assignment
      • Troubleshoot Reviewer Assignment
      • PagerDuty Integration for Reviewers
      • How to Set Up FlexReview Validation
      • Recommended Slack Notification Settings
      • How to Exclude OOO Reviewers
    • FlexReview Reference
      • Configuration
      • Slash commands
      • Expert scoring algorithms
      • Slack Notifications
      • Out of Office User Exclusion
    • FlexReview Roadmap
  • MergeQueue
    • Getting Started with MergeQueue
    • Merge Rules
    • How-to Guides for MergeQueue
      • How to Configure Base Branches
      • How to Customize Required Checks
      • How to Set Up Fast-Forwarding
      • How to Set Up Pre-Queue Conditions
      • How to Queue / Dequeue via API
      • Pause / Unpause Queues via API
      • Slash Commands Using GitHub Comments
      • How to Customize Sticky Comments
      • Require an Aviator Status Check
      • Backport a PR
      • How to Configure ChangeSets
      • Custom Integrations
        • GitHub Integration
      • How to Create Personal Access Tokens
      • How to Set Up SAML Configuration
        • Microsoft Active Directory
      • How to Merge Stacked PRs
      • How to Block Pull Request Mergeing with Slash Commands
    • Concepts for MergeQueue
      • Queue Modes
      • Pull Request Lifecycle
      • Analytics
      • Parallel Mode
      • CI Status Requirements
      • MQ Created Branches
      • Batching
      • Managing flaky tests
      • Fast-forwarding
      • Pre-Queue Conditions
      • Sticky Comments
      • Backporting
      • Paused Queues
      • Affected Targets
        • Directory-Based Affected Targets
        • nx based affected targets
        • GitHub Actions based Affected Targets
      • ChangeSets
        • Global CI Validation
        • ChangeSets FAQs
      • Priority Merges
        • Instant Merges
      • Merge Rules Audit Trail
      • Timeline
      • Ready Hook
      • Reduce Queue Failures From Staleness
    • MergeQueue References
      • Configuration Schema
      • Configuration Reference MergeQueue
      • GitHub Slash Commands
      • Status Codes
  • Stacked PRs CLI
    • Quickstart for Stacked PRs CLI
    • CLI Installation
    • How-to Guides for Stacked PRs CLI
      • How to Create Stacked PRs in CLI
      • How to Navigate & Modify Stacked PRs
      • Add Commits in the Stack
      • How Split a Commit in CLI
      • How to Split and Fold Pull Requests
      • How to Rename a Branch in CLI
      • How to Adopt a Branch in CLI
      • Orphan a Branch with Aviator CLI
      • How to Do Git Subcommand Aliasing
      • How to Create an Access Token
      • How to Set Up Auto Completion in CLI
      • How to Use Editor Plugins in CLI
    • Concepts for StackedPRs CLI
    • How to Rebase and Sync with GitHub
    • Configuration for StackedPRs CLI
    • Stacked PRs FAQs and Troubleshooting
      • Working with Aviator CLI
      • Default Branch Update Master to Main
    • Manpages for Stacked PRs CLI
      • av(1)
      • av-adopt Command Guide
      • av-auth-status(1) in CLI
      • av-stack-branch(1) in CLI
      • av-commit-create(1) in CL
      • av-stack-diff(1) in CLI
      • av-fetch(1) in CLI
      • av-git-interaction Command Guide
      • av-init(1) in CLI
      • av-stack-next(1) in CLI
      • av-orphan Command Guide
      • av-pr-status(1) in CLI
      • av-pr-create(1) in CLI
      • av-stack-prev(1) in CLI
      • av-stack-reorder(1) in CLI
      • av-reparent Command Guide
      • av-restack Command Guide
      • av-commit-split(1) in CLI
      • av-switch Command Guide
      • av-stack-sync(1) in CLI
      • av-stack-tidy(1) in CLI
      • av-stack-tree(1) in CLI
    • Aviator CLI Major Releases
      • Aviator CLI v0.1.0 Release Notes
  • Aviator's Chrome Extension
  • Pilot Automated Actions
    • Scheduled Events
    • JavaScript Execution
    • Pilot Automated Actions Reference
      • GitHub Reference
      • MergeQueue Reference
      • Slack Reference
  • API and Integrations
    • Slack Integration Guide
    • GraphQL API Quickstart
    • Prometheus Metrics Setup for GCP
    • Reference
      • JSON API
      • GraphQL
      • Webhooks
      • Monitoring Metrics
  • Manage
    • Access Management
    • GitHub App Permissions
    • Security
      • Aviator Agents Data Usage & Retention Policy
    • On-Premise Installation
      • GitHub App for On-Prem
      • GitHub OAuth for On-Prem
      • Use Helm Instructions
      • Use Docker Compose Instructions
      • Prometheus endpoint
      • Slack Integration for On-Premise
      • Google SSO Login for On-Prem
    • FAQs
      • Troubleshooting GitHub app connection
      • MergeQueue FAQs
      • Billing FAQs
Powered by GitBook
On this page
  • Global Context
  • $aviator or aviator
  • $github
  • $slack
  • $mergequeue
  • console
  • Local Context
  • PullRequestEvent
  • PullRequestReviewEvent
  • MergeQueueEvent
  • Event Objects

Was this helpful?

  1. Pilot Automated Actions

JavaScript Execution

Aviator allows for executing custom JS code with Pilot automated actions or the MergeQueue ready hook. Learn more details about how it happens in our guide.

PreviousScheduled EventsNextPilot Automated Actions Reference

Last updated 8 months ago

Was this helpful?

Aviator has support for executing custom JavaScript code using or the .

For security and sandboxing purposes, The Pilot JavaScript execution does not provide most standard web APIs (such as fetch). Instead, several integrations with , , and are provided.

Each Javascript code execution has maximum time limit of 10 seconds, and you can write arbitrary javascript within the bounds of provided APIs and context.

Global Context

For each Javascript execution, Aviator provides the a few variables for global context. These variables can be used to query data or take action.

$aviator or aviator

Represents the top level context. It has 3 properties: github, slack and mergequeue. These properties can also be used directly with $github, $slack and $mergequeue respectively. Example:

aviator.github.addLabel({ label: "urgent", target: event.pullRequest.id });

or

$aviator.mergequeue.synchronizePullRequest({target: event.pullRequest.id});

$github

Corresponds to the component, and can also be used directly. Example:

$github.addLabel({ label: "urgent", target: event.pullRequest.id });

$slack

Corresponds to the component and can also be used directly. Example:

$slack.channel({text: "A reset was caused by PR#" + event.pullRequest.number })

$mergequeue

$mergequeue.copyPullRequest({branch: "c/" + event.pullRequest.head.ref})

console

Represents the standard javascript console. Although these console logs are not captured anywhere.

Local Context

PullRequestEvent

Associated with a pull_request trigger. It has a the following properties:

  • event.pullRequest - a PullRequest object

  • event.action - string representing the action on the pull request.

  • event.sender - a GitHubUser object representing the user who took the action on the pull request

  • event.repository - a GitHub repository object

PullRequestReviewEvent

Associated with a pull_request_review trigger. It has the following properties:

  • event.pullRequest - a PullRequest object

  • event.action - string representing the action on the pull request.

  • event.sender - a GitHubUser object representing the user who took the action on the pull request

  • event.repository - a GitHubRepository object

  • event.review - a Review object

MergeQueueEvent

Associated with a merge_queue trigger. It has the following properties:

  • event.pullRequest - a PullRequest object

  • event.action - string representing the action on the pull request

  • event.repository - a GitHubRepository object

Event Objects

PullRequest

  • url - string representing the URL of the pull request. E.g. https://github.com/aviator-co/mergeit/pull/6301

  • number - integer representing PR number, e.g.: 6301

  • state - string representing state of the PR, possible values: open, pending, queued, blocked and merged

  • user - a GitHubUser object representing the author of the PR

  • skipLine - boolean. True when the PR is a skip-line label (associated with MergeQueue)

  • skipLineReason - string (optional). If skip line reason was provided

  • id - representing a unique identifier for a pull request. e.g. aviator-co/mergeit#6301

  • base - a PullRequestRef object representing the base branch of this PR.

  • head - a PullRequestRef object representing the head branch of this PR.

PullRequestRef

  • ref - string representing a branch, e.g. master

GitHubUser

  • login - string representing the GitHub username

GitHubRepository

  • name - string representing the name of the repository, e.g. mergeit

  • fullName - string representing the org name and repository name together, e.g. aviator-co/mergeit

Review

  • user - The GithubUser who submitted the review

  • body - string representing the contents of the review

  • state - string representing approved, changes_requested, commented

Corresponds to the component, and can be used directly. Example:

For each Javascript execution, Aviator also provides a local context associated with the trigger that caused the javascript to be executed. This is defined as event object. An event can be of multiple types. Each represents one even type:

Pilot automated actions
MergeQueue ready hook
MergeQueue
GitHub
Slack
GitHub
Slack
MergeQueue
trigger event