Template Content
Not the template you're looking for? Browse more.
About ScriptRunner Connect
What is ScriptRunner Connect?
Can I try it out for free?
Yes. ScriptRunner Connect comes with a forever free tier.
Can I customize the integration logic?
Absolutely. The main value proposition of ScriptRunner Connect is that you'll get full access to the code that is powering the integration, which means you can make any changes to the the integration logic yourself.
Can I change the integration to communicate with additional apps?
Yes. Since ScriptRunner Connect specializes in enabling complex integrations, you can easily change the integration logic to connect to as many additional apps as you need, no limitations.
What if I don't feel comfortable making changes to the code?
First you can try out our AI assistant which can help you understand what the code does, and also help you make changes to the code. Alternatively you can hire our professionals to make the changes you need or build new integrations from scratch.
Do I have to host it myself?
No. ScriptRunner Connect is a fully managed SaaS (Software-as-a-Service) product.
What about security?
ScriptRunner Connect is ISO 27001 and SOC 2 certified. Learn more about our security.
This integration automatically creates Compass components when new GitHub repositories are created for Organisation. When a repository is created on GitHub, a webhook event triggers the creation of a corresponding SERVICE-type component in Compass with a direct link to the repository.
This template was developed with the assistance of an AI agent.
What it does:
Business value:
Jira Cloud Connector (for Compass)
read:component:compass, write:component:compassCompass GraphQLGitHub Repository Event Listener
application/jsonCLOUD_ID (Text)
https://your-domain.atlassian.net/_edge/tenant_info (replace your-domain with your site's name)a1b2c3d4e5f6g7h8i9j0k1l2COMPONENT_TYPE (Text)
APPLICATION, LIBRARY, SERVICE, OTHERSERVICEUsing Event Listener Test Payload:
Creating a Test Repository:
COMPONENT_TYPE parameter value (default: SERVICE)COMPONENT_TYPE parameter. Valid values are APPLICATION, LIBRARY, SERVICE, or OTHER. Default to SERVICE if not specified.import CompassGraphQL from './api/compass';
import { RepositoryEvent } from '@sr-connect/github/events';
import { mutation as buildMutation } from 'gql-query-builder';
/**
* Event listener script that automatically creates Compass components when GitHub repositories are created.
*
* This script is triggered by GitHub repository webhook events and creates a corresponding
* component in Compass with a link to the repository. Only processes 'created' actions and skips other
* repository events (e.g., deleted, archived).
*
* @param event - GitHub repository event containing repository details and action type
* @param context - ScriptRunner Connect context providing environment variables and invocation metadata
*/
export default async function (event: RepositoryEvent, context: Context<EV>): Promise<void> {
const CLOUD_ID = context.environment.vars.CLOUD_ID;
const TYPE = context.environment.vars.COMPONENT_TYPE;
// Prevent manual execution - this script should only be triggered via Event Listener
// Manual testing should use the Event Listener's Test Event Payload feature
if (context.triggerType === 'MANUAL') {
console.error(
'This script is designed to be triggered externally or manually from the Event Listener. Please consider using Event Listener Test Event Payload if you need to trigger this script manually.',
);
return;
}
// Extract repository information from the GitHub webhook event
const action = event.action;
const name = event.repository.name;
const description = event.repository.description;
const url = event.repository.html_url;
// Build GraphQL mutation to create a Compass component
// Uses gql-query-builder to construct the mutation with proper type safety
const { query, variables } = buildMutation(
{
operation: 'compass',
fields: [
{
operation: 'createComponent',
variables: {
// Jira Cloud ID required for Compass API - identifies the Atlassian site
cloudId: {
value: CLOUD_ID,
type: 'ID',
required: true,
},
// Component creation input with repository details
input: {
value: {
name,
typeId: TYPE, // Component type - by default SERVICE represents a service/application
description,
// Link to the GitHub repository for easy navigation from Compass
links: [
{
name: 'Repository',
type: 'REPOSITORY',
url,
},
],
},
type: 'CreateCompassComponentInput',
required: true,
},
},
// Request specific fields in the response for validation and logging
fields: [
'success',
{
componentDetails: ['id', 'name', 'description', 'typeId'],
},
{
errors: ['message'],
},
],
},
],
},
null,
{
operationName: 'CreateComponent',
},
);
// Only process repository creation events - skip other actions (deleted, archived, etc.)
if (action === 'created') {
// Execute GraphQL mutation via Compass API Connection
// The API Connection handles authentication automatically
const response = await CompassGraphQL.fetch('/gateway/api/graphql', {
method: 'POST',
body: JSON.stringify({ query, variables }),
});
const componentCreated = await response.json();
// Log success for monitoring and debugging
if (componentCreated.data.compass.createComponent.success) {
console.log(`Created component for repository "${name}" - ${url}`);
} else {
console.log('Component creation may have failed:', componentCreated);
}
} else {
console.log('Skipping event. Reason: ', action);
}
}
© 2025 ScriptRunner · Terms and Conditions · Privacy Policy · Legal Notice · Cookie Preferences