Template Content
About the template
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 template demonstrates how to create a new page in Confluence Data Center (or server) when a new issue is created in Jira Data Center (or server).
When you create a new issue in Jira On-Premise, a new page will be created in Confluence On-Premise, under the specified space key.
import ConfluenceOnPremise from './api/confluence/on-premise';
import { IssueCreatedEvent } from '@sr-connect/jira-on-premise/events';
/**
* This function creates a new page in Confluence On-Premise when Issue Created event is received from Jira On-Premise
*
* @param event Object that holds Issue Created event data
* @param context Object that holds function invocation context data
*/
export default async function (event: IssueCreatedEvent, context: Context): Promise<void> {
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;
}
const { SPACE_KEY } = getEnvVars(context);
// Create a new page in Confluence with a content constructed from the Issue Created event
const page = await ConfluenceOnPremise.Content.createContent({
body: {
type: 'page',
space: {
key: SPACE_KEY
},
title: event.issue.key,
body: {
wiki: {
representation: 'wiki', // Using wiki representation because the description from Jira On-Premise side comes through as wiki markup so it doesn't require any further transformation
value: `*Summary:* ${event.issue.fields.summary}\n*Issue Type:* ${event.issue.fields.issuetype?.name}\n*Status:* ${event.issue.fields.status?.name}\n*Reporter:* ${event.issue.fields.reporter?.displayName}\n*Assignee*: ${event.issue.fields.assignee?.displayName ?? 'Unassigned'}\n*Created Date:* ${new Date(event.issue.fields.created ?? 0).toUTCString()}\n*Description:*\n${event.issue.fields.description ?? ''}`
}
}
}
});
// Print out the ID of the newly created page
console.log(`Name page created with ID: ${page.id}`);
}
interface EnvVars {
SPACE_KEY: string;
}
export function getEnvVars(context: Context) {
return context.environment.vars as EnvVars;
}