Skip to content

Commit

Permalink
Merge pull request #1173 from vbfox/appveyor_artifacts
Browse files Browse the repository at this point in the history
Add artifact publishing to AppVeyor
  • Loading branch information
forki committed Mar 13, 2016
2 parents ca959b4 + a7bc6ce commit ed7a31c
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/app/FakeLib/AppVeyor.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/// Contains code to configure FAKE for AppVeyor integration
module Fake.AppVeyor

open System.IO

/// AppVeyor environment variables as [described](http://www.appveyor.com/docs/environment-variables)
type AppVeyorEnvironment =

Expand Down Expand Up @@ -177,3 +179,57 @@ let UploadTestResultsXml (testResultsType : TestResultsType) outputDir =
|> Async.Parallel
|> Async.RunSynchronously
|> ignore

/// Set environment variable
let SetVariable name value =
sendToAppVeyor <| sprintf "SetVariable -Name \"%s\" -Value \"%s\"" name value

/// Type of artifact that is pushed
type ArtifactType = Auto | WebDeployPackage

/// AppVeyor parameters for artifact push
type PushArtifactParams =
{
/// The full local path to the artifact
Path: string
/// File name to display in the artifact tab
FileName: string
/// Deployment name
DeploymentName: string
/// Type of the artifact
Type: ArtifactType
}

/// AppVeyor artifact push default parameters
let defaultPushArtifactParams =
{
Path = ""
FileName = ""
DeploymentName = ""
Type = Auto
}

let private appendArgIfNotNullOrEmpty value name builder =
if (isNotNullOrEmpty value) then
appendWithoutQuotes (sprintf "-%s \"%s\"" name value) builder
else
builder

/// Push an artifact
let PushArtifact (setParams : PushArtifactParams -> PushArtifactParams) =
if buildServer = BuildServer.AppVeyor then
let parameters = setParams defaultPushArtifactParams
new System.Text.StringBuilder()
|> append "PushArtifact"
|> append parameters.Path
|> appendArgIfNotNullOrEmpty parameters.FileName "FileName"
|> appendArgIfNotNullOrEmpty parameters.DeploymentName "DeploymentName"
|> appendArgIfNotNullOrEmpty (sprintf "%A" parameters.Type) "Type"
|> toText
|> sendToAppVeyor

/// Push multiple artifacts
let PushArtifacts paths =
if buildServer = BuildServer.AppVeyor then
for path in paths do
PushArtifact (fun p -> { p with Path = path; FileName = Path.GetFileName(path) })

0 comments on commit ed7a31c

Please sign in to comment.