Bamboo支持PowerShell DSC吗?

时间:2015-01-02 19:12:15

标签: powershell bamboo

我正在使用powershell dsc来部署我的.net应用程序。

这是代码。它非常简单,只是将已编译的代码从bamboo服务器移动到dev服务器。 如果我只在Bamboo服务器上运行powershell脚本,它可以工作。我看到编译的代码被移动到开发服务器。

Configuration MvcWebTest {

    Param(
        [String[]]$ComputerName = "tvw-irwebsvc",
        $AppName = "Test",
        $User = "PAOMSvc",
        $Password = "Welcome1"
    )

    Node $ComputerName {
        File MonitoringInstallationFiles {
            Ensure ="Present";
            SourcePath ="\\DVW-MORBAM01\Build\Publish\MvcWebTest\Dev";
            DestinationPath="C:\ps\dest";
            Type = "Directory";
            Recurse = $True
        }
    }
}

然后我创建了一个Bamboo部署项目来运行这个PowerShell脚本。 status显示成功,但文件没有移动到开发服务器。

竹子支持PowerShell DSC吗?我还能检查什么? 这是日志

simple  02-Jan-2015 13:35:43    Build Deployment of 'release-4' on 'Dev' started building on agent Default Agent
simple  02-Jan-2015 13:35:43    Build working directory is C:\bamboo-home\xml-data\build-dir\1736705-1802241
simple  02-Jan-2015 13:35:43    Executing build Deployment of 'release-4' on 'Dev'
simple  02-Jan-2015 13:35:43    Starting task 'Clean working directory task' of type 'com.atlassian.bamboo.plugins.bamboo-artifact-downloader-plugin:cleanWorkingDirectoryTask'
simple  02-Jan-2015 13:35:43    Cleaning working directory 'C:\bamboo-home\xml-data\build-dir\1736705-1802241'
simple  02-Jan-2015 13:35:43    Finished task 'Clean working directory task' with result: Success
simple  02-Jan-2015 13:35:43    Starting task 'Download release contents' of type 'com.atlassian.bamboo.plugins.bamboo-artifact-downloader-plugin:artifactdownloadertask'
simple  02-Jan-2015 13:35:43    Finished task 'Download release contents' with result: Success
simple  02-Jan-2015 13:35:43    Starting task 'PowerShell Deployment Script' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.script'
command 02-Jan-2015 13:35:43    Beginning to execute external process for build 'Deployment of 'release-4' on 'Dev''\n ... running command line: \n\\DVW-MORBAM01\Build\Scripts\MvcWebTest.ps1\n ... in: C:\bamboo-home\xml-data\build-dir\1736705-1802241\n ... using extra environment variables: \nbamboo_deploy_environment=Dev\nbamboo_capability_system_jdk_JDK_1_7=C:\Program Files\Java\jdk1.7.0_71\nbamboo_planRepository_type=stash-rep\nbamboo_shortPlanName=website\nbamboo_resultsUrl=http://dvw-morbam01:8085/deploy/viewDeploymentResult.action?deploymentResultId=2359302\nbamboo_capability_system_jdk_JDK_1_7_0_71=C:\Program Files\Java\jdk1.7.0_71\nbamboo_planKey=MVCWEB-WEB\nbamboo_deploy_rollback=false\nbamboo_planRepository_1_revision=c86de962b8937e0e1d848146272c33dd9ea12195\nbamboo_ManualBuildTriggerReason_userName=jqin\nbamboo_planRepository_1_type=stash-rep\nbamboo_planRepository_1_branchName=master\nbamboo_planRepository_1_name=MvcWebTest\nbamboo_deploy_release=release-4\nbamboo_shortPlanKey=WEB\nbamboo_planRepository_branch=master\nbamboo_planRepository_username=\nbamboo_planRepository_branchName=master\nbamboo_build_working_directory=C:\bamboo-home\xml-data\build-dir\1736705-1802241\nbamboo_capability_system_jdk_JDK=C:\Program Files\Java\jdk1.7.0_71\nbamboo_deploy_version_previous=release-3\nbamboo_planRepository_1_branch=master\nbamboo_capability_system_builder_msbuild_MSBuild_v4_0__64bit_=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe\nbamboo_agentId=131073\nbamboo_planRepository_1_repositoryUrl=ssh://git@dvw-stash01:7999/ct/mvcwebtest.git\nbamboo_planRepository_repositoryUrl=ssh://git@dvw-stash01:7999/ct/mvcwebtest.git\nbamboo_planName=MvcWebTest - website\nbamboo_capability_system_builder_devenv_Visual_Studio_Professional_2012=C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\nbamboo_planRepository_revision=c86de962b8937e0e1d848146272c33dd9ea12195\nbamboo_capability_system_builder_msbuild_MSBuild_v2_0__64bit_=C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe\nbamboo_buildResultKey=MVCWEB-WEB-9\nbamboo_capability_system_builder_msbuild_MSBuild_v2_0__32bit_=C:\Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe\nbamboo_deploy_version=release-4\nbamboo_working_directory=C:\bamboo-home\xml-data\build-dir\1736705-1802241\nbamboo_planRepository_1_username=\nbamboo_planRepository_name=MvcWebTest\nbamboo_deploy_release_previous=release-3\nbamboo_buildNumber=9\nbamboo_agentWorkingDirectory=C:\bamboo-home\xml-data\build-dir\nbamboo_deploy_project=MvcWebTest\nbamboo_capability_system_builder_msbuild_MSBuild_v4_0__32bit_=C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe\n
simple  02-Jan-2015 13:35:44    Finished task 'PowerShell Deployment Script' with result: Success
simple  02-Jan-2015 13:35:44    Finalising the build...
simple  02-Jan-2015 13:35:44    Stopping timer.
simple  02-Jan-2015 13:35:44    Build 1736705-1802241-2359302 completed.
simple  02-Jan-2015 13:35:44    Finished processing deployment result Deployment of 'release-4' on 'Dev'

更新

Mathias,谢谢你的帮助。还有一个问题。我将PS脚本移动到目标服务器(tvw-irwebsvc)。在竹子部署项目中,我有以下代码。

        $username = "CFI\Abcd"
        $password = ConvertTo-SecureString -String "Abcd1234567" -AsPlainText -Force
        $creds = New-Object System.Management.Automation.PSCredential $username,$password

        $DSCTargetComputer = New-CimSession -ComputerName "tvw-irwebsvc" -Credential $creds

        Start-DscConfiguration -Wait -Verbose -Path "C:\ps\MvcWebText\" -CimSession $DSCTargetComputer

我收到一条新的错误消息。我检查了目标计算机“tvw-irwebsvc”。 powershell脚本文件就在那里。

            02-Jan-2015 15:14:50    Start-DscConfiguration : C:\ps\MvcWebText\ is not a valid directory.
            02-Jan-2015 15:14:50    At \\DVW-MORBAM01\Build\Scripts\MvcWebTest.ps1:7 char:1
            02-Jan-2015 15:14:50    + Start-DscConfiguration -Path "C:\ps\MvcWebText\" -CimSession 
            02-Jan-2015 15:14:50    $DSCTargetComputer
            02-Jan-2015 15:14:50    + 
            02-Jan-2015 15:14:50    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            02-Jan-2015 15:14:50        + CategoryInfo          : NotSpecified: (:) [Start-DscConfiguration], Argu 
            02-Jan-2015 15:14:50       mentException
            02-Jan-2015 15:14:50        + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.De 
            02-Jan-2015 15:14:50       siredStateConfiguration.Commands.StartDscConfigurationCommand

1 个答案:

答案 0 :(得分:2)

您自己不执行配置,您需要使用Start-DscConfiguration启动目标节点(您要部署到的Web服务器)上的DSC:

# Set up credentials if necessary
$username = "DOMAIN\deployuser"
$password = ConvertTo-SecureString -String "p4ssw0rd" -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential $username,$password

# Connect to the target machine
$DSCTargetComputer = New-CimSession -ComputerName "webserver" -Credential $creds

# Process the configuration
Start-DscConfiguration -Path "D:\Configs\MvcWebText\" -CimSession $DSCTargetComputer

您还可以等待配置完成申请-Wait

Start-DscConfiguration -Wait ...