Exemple #1
0
        /// <summary>
        /// Determines the build server on which the build is running.
        /// </summary>
        /// <param name="context">The Cake context.</param>
        /// <returns>The build server on which the build is running or <c>null</c> if unknown build server.</returns>
        private static IIssuesBuildServer DetermineBuildServer(IssuesContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            // Could be simplified once https://github.com/cake-build/cake/issues/1684 / https://github.com/cake-build/cake/issues/1580 are fixed.
            if (!string.IsNullOrWhiteSpace(context.EnvironmentVariable("TF_BUILD")) &&
                !string.IsNullOrWhiteSpace(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")) &&
                (
                    new Uri(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")).Host == "dev.azure.com" ||
                    new Uri(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")).Host.EndsWith("visualstudio.com", StringComparison.InvariantCulture)
                ))
            {
                context.Information("Build server detected: {0}", "Azure Pipelines");
                return(new AzureDevOpsBuildServer());
            }

            if (context.AppVeyor().IsRunningOnAppVeyor)
            {
                context.Information("Build server detected: {0}", "AppVeyor");
                return(new AppVeyorBuildServer());
            }

            if (context.GitHubActions().IsRunningOnGitHubActions)
            {
                context.Information("Build server detected: {0}", "GitHub Actions");
                return(new GitHubActionsBuildServer());
            }

            return(null);
        }
Exemple #2
0
        /// <inheritdoc />
        public override string DetermineCommitId(
            IssuesContext context,
            DirectoryPath repositoryRootDirectory)
        {
            context.NotNull(nameof(context));

            return(context.GitHubActions().Environment.Workflow.Sha);
        }
Exemple #3
0
        /// <inheritdoc />
        public override Uri DetermineRepositoryRemoteUrl(
            IssuesContext context,
            DirectoryPath repositoryRootDirectory)
        {
            context.NotNull(nameof(context));

            return(new Uri($"https://github.com/{context.GitHubActions().Environment.Workflow.Repository}.git"));
        }
Exemple #4
0
        /// <inheritdoc />
        public override bool DetermineIfPullRequest(IssuesContext context)
        {
            context.NotNull(nameof(context));

            return(context.GitHubActions().Environment.PullRequest.IsPullRequest);
        }