diff --git a/src/Cake.Common.Tests/Unit/Build/AzurePipelines/Data/AzurePipelinesPullRequestInfoTests.cs b/src/Cake.Common.Tests/Unit/Build/AzurePipelines/Data/AzurePipelinesPullRequestInfoTests.cs
index e0b95cd2ed..83f832f0b7 100644
--- a/src/Cake.Common.Tests/Unit/Build/AzurePipelines/Data/AzurePipelinesPullRequestInfoTests.cs
+++ b/src/Cake.Common.Tests/Unit/Build/AzurePipelines/Data/AzurePipelinesPullRequestInfoTests.cs
@@ -33,6 +33,22 @@ public void Should_Return_Correct_Value(string value, bool expected)
}
public sealed class TheIdProperty
+ {
+ [Fact]
+ public void Should_Return_Correct_Value()
+ {
+ // Given
+ var info = new AzurePipelinesInfoFixture().CreatePullRequestInfo();
+
+ // When
+ var result = info.Id;
+
+ // Then
+ Assert.Equal(1, result);
+ }
+ }
+
+ public sealed class TheLongIdProperty
{
[Theory]
[InlineData("1", 1)]
@@ -45,7 +61,7 @@ public void Should_Return_Correct_Value(string value, long expected)
var info = fixture.CreatePullRequestInfo();
// When
- var result = info.Id;
+ var result = info.LongId;
// Then
Assert.Equal(expected, result);
diff --git a/src/Cake.Common/Build/AzurePipelines/Data/AzurePipelinesPullRequestInfo.cs b/src/Cake.Common/Build/AzurePipelines/Data/AzurePipelinesPullRequestInfo.cs
index cf1742e6c2..dea6c332fc 100644
--- a/src/Cake.Common/Build/AzurePipelines/Data/AzurePipelinesPullRequestInfo.cs
+++ b/src/Cake.Common/Build/AzurePipelines/Data/AzurePipelinesPullRequestInfo.cs
@@ -32,7 +32,7 @@ public AzurePipelinesPullRequestInfo(ICakeEnvironment environment)
///
/// true if the current build was started by a pull request; otherwise, false.
///
- public bool IsPullRequest => Id > 0;
+ public bool IsPullRequest => LongId > 0;
///
/// Gets the ID of the pull request that caused this build.
@@ -41,7 +41,17 @@ public AzurePipelinesPullRequestInfo(ICakeEnvironment environment)
///
/// The ID of the pull request that caused this build.
///
- public long Id => GetEnvironmentLongInteger("SYSTEM_PULLREQUEST_PULLREQUESTID");
+ [Obsolete("Type will change in next major version to long, meanwhile use LongId to ensure proper value returned.")]
+ public int Id => GetEnvironmentInteger("SYSTEM_PULLREQUEST_PULLREQUESTID");
+
+ ///
+ /// Gets the ID of the pull request that caused this build.
+ /// This value is set only if the build ran because of a Git PR affected by a branch policy.
+ ///
+ ///
+ /// The ID of the pull request that caused this build.
+ ///
+ public long LongId => GetEnvironmentLongInteger("SYSTEM_PULLREQUEST_PULLREQUESTID");
///
/// Gets the number of the pull request that caused this build.