Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Cake.Common/Build/GitLabCI/Data/GitLabCIBuildInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public GitLabCIBuildInfo(ICakeEnvironment environment)
/// <value>
/// The build ID.
/// </value>
public int Id => GetEnvironmentInteger("CI_JOB_ID", "CI_BUILD_ID");
public long Id => GetEnvironmentLong("CI_JOB_ID", "CI_BUILD_ID");

/// <summary>
/// Gets the commit revision for which project is built.
Expand Down Expand Up @@ -106,23 +106,23 @@ public GitLabCIBuildInfo(ICakeEnvironment environment)
/// <value>
/// The unique build ID.
/// </value>
public int PipelineId => GetEnvironmentInteger("CI_PIPELINE_ID");
public long PipelineId => GetEnvironmentLong("CI_PIPELINE_ID");

/// <summary>
/// Gets the unique id of the current pipeline scoped to the project.
/// </summary>
/// <value>
/// The unique build ID.
/// </value>
public int PipelineIId => GetEnvironmentInteger("CI_PIPELINE_IID");
public long PipelineIId => GetEnvironmentLong("CI_PIPELINE_IID");

/// <summary>
/// Gets the id of the user who started the build.
/// </summary>
/// <value>
/// The user ID.
/// </value>
public int UserId => GetEnvironmentInteger("GITLAB_USER_ID");
public long UserId => GetEnvironmentLong("GITLAB_USER_ID");

/// <summary>
/// Gets the email of the user who started the build.
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Common/Build/GitLabCI/Data/GitLabCIProjectInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public GitLabCIProjectInfo(ICakeEnvironment environment)
/// <value>
/// The project ID.
/// </value>
public int Id => GetEnvironmentInteger("CI_PROJECT_ID");
public long Id => GetEnvironmentLong("CI_PROJECT_ID");

/// <summary>
/// Gets the project name that is currently being built.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public GitLabCIPullRequestInfo(ICakeEnvironment environment)
/// <value>
/// The pull request id.
/// </value>
public int Id => GetEnvironmentInteger("CI_MERGE_REQUEST_ID");
public long Id => GetEnvironmentLong("CI_MERGE_REQUEST_ID");

/// <summary>
/// Gets the pull request id scoped to the project.
/// </summary>
/// <value>
/// The pull request id.
/// </value>
public int IId => GetEnvironmentInteger("CI_MERGE_REQUEST_IID");
public long IId => GetEnvironmentLong("CI_MERGE_REQUEST_IID");

/// <summary>
/// Gets the source branch of the pull request.
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Common/Build/GitLabCI/Data/GitLabCIRunnerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public GitLabCIRunnerInfo(ICakeEnvironment environment)
/// <value>
/// The unique id of runner being used.
/// </value>
public int Id => GetEnvironmentInteger("CI_RUNNER_ID");
public long Id => GetEnvironmentLong("CI_RUNNER_ID");

/// <summary>
/// Gets the description of the runner as saved in GitLab.
Expand Down
29 changes: 29 additions & 0 deletions src/Cake.Common/Build/GitLabCI/GitLabCIInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,34 @@ protected bool GetEnvironmentBoolean(string primaryVariable, string secondaryVar

return null;
}

/// <summary>
/// Gets an environment variable as a <see cref="System.Int64"/>.
/// </summary>
/// <param name="variable">The environment variable name.</param>
/// <returns>The environment variable.</returns>
protected long GetEnvironmentLong(string variable)
{
var value = GetEnvironmentString(variable);
if (!string.IsNullOrWhiteSpace(value))
{
if (long.TryParse(value, out long result))
{
return result;
}
}
return 0;
}

/// <summary>
/// Gets an environment variable as a <see cref="System.Int64"/>.
/// </summary>
/// <param name="primaryVariable">The primary environment variable name.</param>
/// <param name="secondaryVariable">The secondary environment variable name.</param>
/// <returns>The environment variable.</returns>
protected long GetEnvironmentLong(string primaryVariable, string secondaryVariable)
{
return GetEnvironmentLong(primaryVariable) != 0 ? GetEnvironmentLong(primaryVariable) : GetEnvironmentLong(secondaryVariable);
}
}
}
Loading