diff --git a/FluentTc.Tests/LocalTcTests.cs b/FluentTc.Tests/LocalTcTests.cs index a170a94..289bbfc 100644 --- a/FluentTc.Tests/LocalTcTests.cs +++ b/FluentTc.Tests/LocalTcTests.cs @@ -183,5 +183,39 @@ public void IsPersonal_False_False() // Assert isPersonal.Should().BeFalse(); } + + [Test] + public void PublishArtifact_FileName_Published() + { + // Arrange + var teamCityWriterFactory = A.Fake(); + var teamCityWriter = A.Fake(); + A.CallTo(() => teamCityWriterFactory.CreateTeamCityWriter()).Returns(teamCityWriter); + + var localTc = new LocalTc(A.Fake(), teamCityWriterFactory); + + // Act + localTc.PublishArtifact("file.txt"); + + // Assert + A.CallTo(()=>teamCityWriter.PublishArtifact("file.txt")).MustHaveHappened(); + } + + [Test] + public void PublishArtifact_FileNameAndTarget_Published() + { + // Arrange + var teamCityWriterFactory = A.Fake(); + var teamCityWriter = A.Fake(); + A.CallTo(() => teamCityWriterFactory.CreateTeamCityWriter()).Returns(teamCityWriter); + + var localTc = new LocalTc(A.Fake(), teamCityWriterFactory); + + // Act + localTc.PublishArtifact("file.txt", "dir"); + + // Assert + A.CallTo(()=>teamCityWriter.PublishArtifact("file.txt => dir")).MustHaveHappened(); + } } } \ No newline at end of file diff --git a/FluentTc/LocalTc.cs b/FluentTc/LocalTc.cs index 394c8dc..d72ec2d 100644 --- a/FluentTc/LocalTc.cs +++ b/FluentTc/LocalTc.cs @@ -31,6 +31,31 @@ public interface ILocalTc bool IsTeamCityMode { get; } bool IsPersonal { get; } void SetBuildParameter(string parameterName, string parameterValue); + + /// + /// Attaches new artifact publishing rules as described in + /// http://confluence.jetbrains.net/display/TCD7/Build+Artifact + /// + /// + /// Filename to publish. The file name should be relative to the build checkout directory. + /// Directory name to publish all the files and subdirectories within the directory specified. The directory name should be a path relative to the build checkout directory. The files will be published preserving the directories structure under the directory specified (the directory itself will not be included). + /// + void PublishArtifact(string fileDirectoryName); + + /// + /// Attaches new artifact publishing rules as described in + /// http://confluence.jetbrains.net/display/TCD7/Build+Artifact + /// + /// + /// Filename to publish. The file name should be relative to the build checkout directory. + /// Directory name to publish all the files and subdirectories within the directory specified. The directory name should be a path relative to the build checkout directory. The files will be published preserving the directories structure under the directory specified (the directory itself will not be included). + /// + /// + /// Target directory - the directory in the resulting build's artifacts that will contain the files determined by the left part of the pattern. + /// Target archive - the path to the archive to be created by TeamCity by packing build artifacts. + /// TeamCity treats as archive whenever it ends with a supported archive extension, i.e. .zip, .jar, .tar.gz, or .tgz. + /// + void PublishArtifact(string fileDirectoryName, string targetDirectoryArchive); } public class LocalTc : ILocalTc @@ -173,5 +198,37 @@ public bool IsPersonal { get { return m_BuildParameters.IsPersonal; } } + + /// + /// Attaches new artifact publishing rules as described in + /// http://confluence.jetbrains.net/display/TCD7/Build+Artifact + /// + /// + /// Filename to publish. The file name should be relative to the build checkout directory. + /// Directory name to publish all the files and subdirectories within the directory specified. The directory name should be a path relative to the build checkout directory. The files will be published preserving the directories structure under the directory specified (the directory itself will not be included). + /// + public void PublishArtifact(string fileDirectoryName) + { + m_TeamCityWriter.PublishArtifact(fileDirectoryName); + } + + /// + /// Attaches new artifact publishing rules as described in + /// http://confluence.jetbrains.net/display/TCD7/Build+Artifact + /// + /// + /// Filename to publish. The file name should be relative to the build checkout directory. + /// Directory name to publish all the files and subdirectories within the directory specified. The directory name should be a path relative to the build checkout directory. The files will be published preserving the directories structure under the directory specified (the directory itself will not be included). + /// + /// + /// Target directory - the directory in the resulting build's artifacts that will contain the files determined by the left part of the pattern. + /// Target archive - the path to the archive to be created by TeamCity by packing build artifacts. + /// TeamCity treats as archive whenever it ends with a supported archive extension, i.e. .zip, .jar, .tar.gz, or .tgz. + /// + public void PublishArtifact(string fileDirectoryName, string targetDirectoryArchive) + { + // ReSharper disable once UseStringInterpolation + m_TeamCityWriter.PublishArtifact(string.Format("{0} => {1}", fileDirectoryName, targetDirectoryArchive)); + } } } \ No newline at end of file