Create a Google Calendar entry when a new version is released in Jira Cloud


Get Started

Not the template you're looking for? Browse more.

About the template


Create a meeting in Google Calendar when a new version is released in Jira Cloud. Get started to learn more.

About ScriptRunner Connect


What is ScriptRunner Connect?

ScriptRunner Connect is an AI assisted code-first (JavaScript/TypeScript) integration platform (iPaaS) for building complex integrations and automations.

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.

Template Content


README

Scripts

TypeScriptOnJiraCloudVersionCreated
Version Created

README


๐Ÿ“‹ Overview

This template automatically schedules a new 30-minute meeting in Google Calendar whenever a new version is released in Jira Cloud.

๐Ÿ–Š๏ธ Setup

  1. Create connectors for Google Calendar and Jira Cloud (or use existing ones) to set up the API connections and event listener.
  2. Go to Parameters, and set the CALENDAR_ID parameter to match the ID of the calendar where you want the meeting scheduled.

๐Ÿš€ Using the template

When you release a new project version in Jira Cloud, a meeting will be scheduled in your calendar. The meeting will include all users with admin permissions for that project in Jira Cloud.

API Connections


TypeScriptOnJiraCloudVersionCreated

import JiraCloud from './api/jira/cloud';
import GoogleCalendar from './api/google/calendar';
import { VersionReleasedEventType } from '@sr-connect/jira-cloud/events';
import dayjs from 'dayjs';

// This function schedules a new meeting in Google Calendar when Version Released event is received from Jira Cloud
export default async function (event: VersionReleasedEventType, 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 { CALENDAR_ID } = getEnvVars(context);

    // Calculate the meeting time using the timestamp received from the event
    const meetingStart = roundTo15Minutes(event.timestamp);
    const meetingEnd = meetingStart.add(30, 'minutes');

    // Use the project id received from the event to acquire more information about the project
    const project = await JiraCloud.Project.getProject({
        projectIdOrKey: event.version?.projectId?.toString() ?? ''
    });

    // Search for users in Jira Cloud who have admin permission for the project
    const users = await JiraCloud.User.Search.findUsersWithPermissions({
        permissions: 'PROJECT\_ADMIN', projectKey: project.key
    });

    // Filter out apps and other irrelevant user account types
    const validUsers = users.filter(u => u.accountType === 'atlassian' && u.active && u.emailAddress);

    // Extract the users' email addresses and create an array that can be passed into the request body for Google Calendar
    const attendees = validUsers.map(u => ({
        email: u.emailAddress ?? ''
    }));

    // Schedule the meeting
    const response = await GoogleCalendar.Event.createEvent({
        calendarId: CALENDAR_ID,
        body: {
            start: {
                dateTime: meetingStart.toISOString() // Google Calendar expects the time to be in ISO 8601 format
            },
            end: {
                dateTime: meetingEnd.toISOString()
            },
            summary: `Version release for '${project.name}'`,
            description: `<p>Version <b>${event.version.name}</b> of project <b>${project.name}</b> has been released`,
            attendees,
        },
    });

    // Print out a confirmation message
    console.log(`Scheduled a meeting for ${response.start.dateTime ?? response.start.date ?? ''}`);
};

// Helper function that rounds the version release time up to the nearest 15 minutes and returns it as a dayjs value
function roundTo15Minutes(time: number) {
    const timestamp = time.valueOf();
    const roundedTimestamp = Math.ceil(timestamp / 900000) * 900000;
    return dayjs(roundedTimestamp);
};

interface EnvVars {
    CALENDAR_ID: string;
}

export function getEnvVars(context: Context) {
    return context.environment.vars as EnvVars;
}
Documentation ยท Support ยท Suggestions & feature requests