Integrate some GitLab metadata
This commit is contained in:
parent
bb7dafcb7c
commit
732515e0cc
1 changed files with 23 additions and 2 deletions
|
@ -1,7 +1,9 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Nuke.Common;
|
||||
using Nuke.Common.CI;
|
||||
using Nuke.Common.CI.GitLab;
|
||||
using Nuke.Common.Execution;
|
||||
using Nuke.Common.Git;
|
||||
using Nuke.Common.IO;
|
||||
|
@ -22,7 +24,6 @@ class Build : NukeBuild
|
|||
/// - JetBrains Rider https://nuke.build/rider
|
||||
/// - Microsoft VisualStudio https://nuke.build/visualstudio
|
||||
/// - Microsoft VSCode https://nuke.build/vscode
|
||||
|
||||
public static int Main() => Execute<Build>(x => x.Compile);
|
||||
|
||||
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
|
||||
|
@ -32,9 +33,29 @@ class Build : NukeBuild
|
|||
[GitRepository] readonly GitRepository GitRepository;
|
||||
[GitVersion(NoFetch = true, Framework = "net5.0")] readonly GitVersion GitVersion;
|
||||
|
||||
|
||||
[CanBeNull]
|
||||
GitLab CI => GitLab.Instance;
|
||||
|
||||
AbsolutePath SourceDirectory => RootDirectory / "src";
|
||||
AbsolutePath TestsDirectory => RootDirectory / "tests";
|
||||
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
|
||||
|
||||
Target PrintEnv => _ => _
|
||||
.Executes(() =>
|
||||
{
|
||||
if (CI == null)
|
||||
{
|
||||
Logger.Info("Running in local environment");
|
||||
Logger.Info($"Git commit: {GitRepository.Commit}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Info("Running in GitLab CI");
|
||||
Logger.Info($"Git commit: {CI.CommitSha}");
|
||||
Logger.Info($"Pipeline ID: {CI.PipelineId}");
|
||||
}
|
||||
});
|
||||
|
||||
Target Clean => _ => _
|
||||
.Before(Restore)
|
||||
|
@ -53,7 +74,7 @@ class Build : NukeBuild
|
|||
});
|
||||
|
||||
Target Compile => _ => _
|
||||
.DependsOn(Restore)
|
||||
.DependsOn(Restore, PrintEnv)
|
||||
.Executes(() =>
|
||||
{
|
||||
DotNetBuild(s => s
|
||||
|
|
Loading…
Reference in a new issue