async Task <OctopusJiraPayloadData> PrepareOctopusJiraPayload(string eventType,
                                                                      string serverUri,
                                                                      DeploymentResource deployment,
                                                                      IJiraApiDeployment jiraApiDeployment,
                                                                      CancellationToken cancellationToken,
                                                                      EnvironmentResource deploymentEnvironment,
                                                                      DeploymentEnvironmentSettingsMetadataProvider.JiraDeploymentEnvironmentSettings
                                                                      environmentSettings)
        {
            var project = (await mediator.Request(new GetProjectRequest(deployment.ProjectId), cancellationToken)).Project;

            var release    = (await mediator.Request(new GetReleaseRequest(deployment.ReleaseId), cancellationToken)).Release;
            var serverTask = (await mediator.Request(new GetServerTaskRequest(deployment.TaskId), cancellationToken)).Task;

            TenantResource?tenant = null;

            if (deployment.TenantId?.Value is not null)
            {
                tenant = (await mediator.Request(new GetTenantByIdOrNameRequest(deployment.TenantId.Value.ToTenantIdOrName()), cancellationToken)).Resource;
            }

            return(new OctopusJiraPayloadData
            {
                InstallationId = installationIdProvider.GetInstallationId().ToString(),
                BaseHostUrl = store.GetBaseUrl() ?? string.Empty,
                DeploymentsInfo = new JiraPayloadData
                {
                    Deployments = new[]
        void PublishToJira(string token, DeploymentEventType eventType, IDeployment deployment)
        {
            var envSettings =
                deploymentEnvironmentSettingsProvider
                .GetSettings <DeploymentEnvironmentSettingsMetadataProvider.JiraDeploymentEnvironmentSettings>(
                    JiraConfigurationStore.SingletonId, deployment.EnvironmentId) ?? new DeploymentEnvironmentSettingsMetadataProvider.JiraDeploymentEnvironmentSettings();
            var serverUri = serverConfigurationStore.GetServerUri()?.TrimEnd('/');

            if (string.IsNullOrWhiteSpace(serverUri))
            {
                log.Warn("To use Jira integration you must have the Octopus server's external url configured (see the Configuration/Nodes page)");
                return;
            }

            var project = projectStore.Get(deployment.ProjectId);
            var deploymentEnvironment = deploymentEnvironmentStore.Get(deployment.EnvironmentId);
            var release    = releaseStore.Get(deployment.ReleaseId);
            var serverTask = serverTaskStore.Get(deployment.TaskId);

            var data = new OctopusJiraPayloadData
            {
                InstallationId  = installationIdProvider.GetInstallationId().ToString(),
                BaseHostUrl     = store.GetBaseUrl(),
                DeploymentsInfo = new JiraPayloadData
                {
                    Deployments = new[]
 public override void BuildMappings(IResourceMappingsBuilder builder)
 {
     builder.Map <JiraConfigurationResource, JiraConfiguration>()
     .EnrichResource((model, resource) =>
     {
         resource.OctopusInstallationId = installationIdProvider.GetInstallationId().ToString();
         resource.OctopusServerUrl      = serverConfigurationStore.GetServerUri();
     });
     builder.Map <ReleaseNoteOptionsResource, ReleaseNoteOptions>();
 }