@@ -71,6 +71,7 @@ Task("DownloadGitHubReleaseArtifacts")
7171 if ( ! artifactLookup . ContainsKey ( "NuGetExeBuild" ) ) { throw new Exception ( "NuGetExeBuild artifact missing" ) ; }
7272 if ( ! artifactLookup . ContainsKey ( "GemBuild" ) ) { throw new Exception ( "GemBuild artifact missing" ) ; }
7373 if ( ! artifactLookup . ContainsKey ( "GitVersionTfsTaskBuild" ) ) { throw new Exception ( "GitVersionTfsTaskBuild artifact missing" ) ; }
74+ if ( ! artifactLookup . ContainsKey ( "zip" ) ) { throw new Exception ( "zip artifact missing" ) ; }
7475 } ) ;
7576
7677Task ( "Publish-NuGetPackage" )
@@ -174,13 +175,59 @@ Task("Publish-VstsTask")
174175 }
175176} ) ;
176177
178+
179+ Task ( "Publish-DockerImage" )
180+ . IsDependentOn ( "DownloadGitHubReleaseArtifacts" )
181+ . Does ( ( ) =>
182+ {
183+ var returnCode = StartProcess ( "docker" , new ProcessSettings
184+ {
185+ Arguments = "build . --build-arg GitVersionZip=" + artifactLookup [ "zip" ] + " --tag gittools/gitversion"
186+ } ) ;
187+ if ( returnCode != 0 ) {
188+ Information ( "Publish-DockerImage Task failed to build image, but continuing with next Task..." ) ;
189+ publishingError = true ;
190+ }
191+
192+ // Login to dockerhub
193+ returnCode = StartProcess ( "docker" , new ProcessSettings
194+ {
195+ Arguments = "login -u=\" " + EnvironmentVariable ( "DOCKER_USERNAME" ) + "\" -p=\" " + EnvironmentVariable ( "DOCKER_PASSWORD" ) + "\" "
196+ } ) ;
197+ if ( returnCode != 0 ) {
198+ Information ( "Publish-DockerImage Task failed to login, but continuing with next Task..." ) ;
199+ publishingError = true ;
200+ }
201+
202+ // Publish Tag
203+ returnCode = StartProcess ( "docker" , new ProcessSettings
204+ {
205+ Arguments = "push gittools/gitversion:" + tag
206+ } ) ;
207+ if ( returnCode != 0 ) {
208+ Information ( "Publish-DockerImage Task failed push version tag, but continuing with next Task..." ) ;
209+ publishingError = true ;
210+ }
211+
212+ // Publish latest
213+ returnCode = StartProcess ( "docker" , new ProcessSettings
214+ {
215+ Arguments = "push gittools/gitversion:latest"
216+ } ) ;
217+ if ( returnCode != 0 ) {
218+ Information ( "Publish-DockerImage Task failed latest tag, but continuing with next Task..." ) ;
219+ publishingError = true ;
220+ }
221+ } ) ;
222+
177223Task ( "Deploy" )
178224 . IsDependentOn ( "Publish-NuGetPackage" )
179225 . IsDependentOn ( "Publish-NuGetCommandLine" )
180226 . IsDependentOn ( "Publish-MsBuildTask" )
181227 . IsDependentOn ( "Publish-Chocolatey" )
182228// .IsDependentOn("Publish-Gem")
183229 . IsDependentOn ( "Publish-VstsTask" )
230+ . IsDependentOn ( "Publish-DockerImage" )
184231 . Finally ( ( ) =>
185232{
186233 if ( publishingError )
0 commit comments