0

I am using powershell dsc to deploy my .net application.

Here's the code. its very simple, just moved the compiled code from bamboo server to the dev server. If I only run the powershell script in bamboo server, it works. I see compiled codes are moved to the dev server.

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
        }
    }
}

then I created a bamboo deployment project to run this powershell script. status shows success, but files didnt get moved to the dev server.

does bamboo support powershell DSC? what else can I check? here's the log

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'

UPDATE:

Mathias, thanks for your help. still have one more problem. I moved the PS script to the target server (tvw-irwebsvc). in the bamboo deployment project, i have the following code.

        $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

I am getting a new error message. I checked the target computer "tvw-irwebsvc". powershell script file is there.

            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
qinking126
  • 11,385
  • 25
  • 74
  • 124

1 Answers1

2

You don't execute the configuration itself, you need to kick off DSC on the target node (the web server you are deploying to) with Start-DscConfiguration:

# 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

You can also wait for the configuration to finish applying with -Wait

Start-DscConfiguration -Wait ...
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
  • thanks for your help. I got a new error message this time. I updated the post. please take a look. – qinking126 Jan 02 '15 at 20:48
  • AFAIK, the DSC configuration should be on the bamboo server. So the path in `Start-DscConfiguration` should be on the bamboo server/network share. – Frode F. Jan 02 '15 at 22:40
  • If the config is just lying around statically on the bamboo server, then yes, he should point it to that network share. If the config has already been pushed to/pulled by Local Config Manager on the target server, `-Path` can be omitted entirely – Mathias R. Jessen Jan 03 '15 at 15:42