public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken(
            this ICakeContext context)
        {
            context.NotNull(nameof(context));

            var settings = AzureDevOpsBuildSettings.UsingAzurePipelinesOAuthToken();

            return(AzureDevOpsBuild(context, settings));
        }
        public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken(
            this ICakeContext context,
            int buildId)
        {
            context.NotNull(nameof(context));
            buildId.NotNegativeOrZero(nameof(buildId));

            var settings = AzureDevOpsBuildSettings.UsingAzurePipelinesOAuthToken(buildId);

            return(AzureDevOpsBuild(context, settings));
        }
示例#3
0
        public static AzureDevOpsBuild AzureDevOpsBuildUsingAzurePipelinesOAuthToken(
            this ICakeContext context,
            bool throwExceptionIfBuildCouldNotBeFound)
        {
            context.NotNull(nameof(context));

            var settings = AzureDevOpsBuildSettings.UsingAzurePipelinesOAuthToken();

            settings.ThrowExceptionIfBuildCouldNotBeFound = throwExceptionIfBuildCouldNotBeFound;

            return(AzureDevOpsBuild(context, settings));
        }
示例#4
0
            public void Should_Throw_If_System_Access_Token_Env_Var_Is_Empty_And_Correct_Build_Id_With_OAuthToken()
            {
                // Given
                Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
                Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
                Environment.SetEnvironmentVariable("BUILD_BUILDID", "42");
                Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", string.Empty);

                // When
                var result = Record.Exception(() => AzureDevOpsBuildSettings.UsingAzurePipelinesOAuthToken(42));

                // Then
                result.IsInvalidOperationException();
            }
示例#5
0
            public void Should_Throw_If_Collection_Url_Env_Var_Is_Not_Set()
            {
                // Given
                Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", null);
                Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
                Environment.SetEnvironmentVariable("BUILD_BUILDID", "42");
                Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");

                // When
                var result = Record.Exception(() => AzureDevOpsBuildSettings.UsingAzurePipelinesOAuthToken());

                // Then
                result.IsInvalidOperationException();
            }
示例#6
0
            public void Should_Throw_If_Build_Id_Env_Var_Is_Set_But_Ctor_Build_Id_Value_Zero_With_OAuthToken()
            {
                // Given
                var creds = new AzureDevOpsNtlmCredentials();
                Environment.SetEnvironmentVariable("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "https://example.com/collection");
                Environment.SetEnvironmentVariable("SYSTEM_TEAMPROJECT", "MyProject");
                Environment.SetEnvironmentVariable("BUILD_BUILDID", "20");
                Environment.SetEnvironmentVariable("SYSTEM_ACCESSTOKEN", "foo");

                // When
                var result = Record.Exception(() => AzureDevOpsBuildSettings.UsingAzurePipelinesOAuthToken(0));

                // Then
                result.IsArgumentOutOfRangeException("buildId");
            }