Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add updating of build details to AppVeyor #1473

Merged
merged 1 commit into from
Feb 28, 2017
Merged
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
60 changes: 59 additions & 1 deletion src/app/FakeLib/AppVeyor.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// Contains code to configure FAKE for AppVeyor integration
module Fake.AppVeyor

open System
open System.IO

/// AppVeyor environment variables as [described](http://www.appveyor.com/docs/environment-variables)
Expand Down Expand Up @@ -187,7 +188,7 @@ let SetVariable name value =
/// Type of artifact that is pushed
type ArtifactType = Auto | WebDeployPackage

/// AppVeyor parameters for artifact push
/// AppVeyor parameters for artifact push as [described](https://www.appveyor.com/docs/build-worker-api/#push-artifact)
[<CLIMutable>]
type PushArtifactParams =
{
Expand Down Expand Up @@ -234,3 +235,60 @@ let PushArtifacts paths =
if buildServer = BuildServer.AppVeyor then
for path in paths do
PushArtifact (fun p -> { p with Path = path; FileName = Path.GetFileName(path) })

/// AppVeyor parameters for update build as [described](https://www.appveyor.com/docs/build-worker-api/#update-build-details)
[<CLIMutable>]
type UpdateBuildParams =
{ /// Build version; must be unique for the current project
Version : string
/// Commit message
Message : string
/// Commit hash
CommitId : string
/// Commit date
Committed : DateTime option
/// Commit author name
AuthorName : string
/// Commit author email address
AuthorEmail : string
/// Committer name
CommitterName : string
/// Committer email address
CommitterEmail : string }

let private defaultUpdateBuildParams =
{ Version = ""
Message = ""
CommitId = ""
Committed = None
AuthorName = ""
AuthorEmail = ""
CommitterName = ""
CommitterEmail = "" }

/// Update build details
let UpdateBuild (setParams : UpdateBuildParams -> UpdateBuildParams) =
if buildServer = BuildServer.AppVeyor then
let parameters = setParams defaultUpdateBuildParams

let committedStr =
match parameters.Committed with
| Some x -> x.ToString("o")
| None -> ""

System.Text.StringBuilder()
|> append "UpdateBuild"
|> appendArgIfNotNullOrEmpty parameters.Version "Version"
|> appendArgIfNotNullOrEmpty parameters.Message "Message"
|> appendArgIfNotNullOrEmpty parameters.CommitId "CommitId"
|> appendArgIfNotNullOrEmpty committedStr "Committed"
|> appendArgIfNotNullOrEmpty parameters.AuthorName "AuthorName"
|> appendArgIfNotNullOrEmpty parameters.AuthorEmail "AuthorEmail"
|> appendArgIfNotNullOrEmpty parameters.CommitterName "CommitterName"
|> appendArgIfNotNullOrEmpty parameters.CommitterEmail "CommitterEmail"
|> toText
|> sendToAppVeyor

/// Update build version. This must be unique for the current project.
let UpdateBuildVersion version =
UpdateBuild (fun p -> { p with Version = version })