ln.build/ln.build/pipeline/DeployCommand.cs

64 lines
2.5 KiB
C#

using System;
using System.IO;
using ln.build.repositories;
using ln.logging;
namespace ln.build.pipeline
{
public static class DeployCommand
{
public static void Deploy(Stage stage,params string[] arguments)
{
stage.CommandEnvironment.Logger.Log(LogLevel.WARNING, "stage command: deploy not yet implemented");
}
public static void Release(Stage stage,params string[] arguments)
{
stage.CommandEnvironment.Logger.Log(LogLevel.WARNING, "stage command: release not yet implemented");
}
/*
if (stage.CommandEnvironment.Get("REPO_EVENT","").Equals("release"))
{
Repository repository = stage.CommandEnvironment.CIJob?.Repository;
if (repository != null)
{
Release release = repository.GetRelease(int.Parse(stage.CommandEnvironment.Get("RELEASE_ID")));
foreach (string arg in Arguments)
{
string localPath, remoteFileName;
int ie = arg.IndexOf('=');
if (ie == -1)
{
localPath = Path.Combine(stage.CommandEnvironment.WorkingDirectory, arg);
remoteFileName = Path.GetFileName(arg);
} else {
localPath = Path.Combine(stage.CommandEnvironment.WorkingDirectory, arg.Substring(0, ie));
remoteFileName = arg.Substring(ie + 1);
}
stage.CommandEnvironment.Logger.Log(LogLevel.INFO, "Adding {0} to release as {1}", localPath, remoteFileName);
Attachment attachment = release.CreateOrReplaceAttachment( localPath, remoteFileName );
// Cleanup attachments
foreach (Attachment b in release.GetAttachments())
{
if (!b.Equals(attachment) && b.Name.Equals(attachment.Name))
b.Delete();
}
}
} else {
stage.CommandEnvironment.Logger.Log(LogLevel.ERROR, "RELEASE: no repository interface found!");
throw new Exception("Respository needed!");
}
} else {
stage.CommandEnvironment.Logger.Log(LogLevel.INFO, "RELEASE: build is no release build. Ignoring.");
}
*/
}
}