Re: Powershell step in pipeline not executing
I got i straight from the pipeline syntax page (and some online example) and i dont get syntax errors Il giorno giovedì 18 gennaio 2018 17:53:41 UTC+1, Björn Pedersen ha scritto: > > Hi, > > I have no experience with declarative pipelines, > but configFileProvider is a standalone step , not taking a body like you > use it (it's not a withConfigFile...) > > try: > >echo "Getting version for ${env.projectDir}" >configFileProvider([configFile(fileId: > '52c08128-fa6f-4c79-8a43-ff4f6dd13dbd', variable: 'MYSCRIPT')]) >powershell script: "${MYSCRIPT} -projecDir > ${env.projectDir}" >script { res = powershell script: "${MYSCRIPT} -projecDir > ${env.projectDir}" > echo "results: ${res}" >} > > > > > Björn > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e16abc89-8577-41be-8a52-2f9149563694%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Powershell step in pipeline not executing
I tried right now but nothing changed Il giorno giovedì 18 gennaio 2018 17:33:11 UTC+1, slide ha scritto: > > You may want to try naming the variable something else besides "script" > which is a pipeline variable (you use it right below). I might recommand > PSSCRIPT, or something similar. > >> >> -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/46735d94-2e06-40f7-8f9b-8f67d16e4263%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Powershell step in pipeline not executing
I've got a strange problem with a declarative pipeline and powershell, it seems the script is never executed. The script is in a managed file. The pipeline: pipeline { agent any triggers { pollSCM('H * * * *') } tools { msbuild "DefaultMSBuild" } environment { solution = 'Project.sln' project = 'Project\\Project.csproj' projectDir = 'Project\\Project' key = credentials('proget-testauto-apikey') } stages { stage('Build and test') { steps { echo "Getting version for ${env.projectDir}" configFileProvider([configFile(fileId: '52c08128-fa6f-4c79-8a43-ff4f6dd13dbd', variable: 'script')]) { powershell script: "${script} -projecDir ${env.projectDir}" script { res = powershell script: "${script} -projecDir ${env.projectDir}" echo "results: ${res}" } } echo 'Restore nugets..' bat "%NUGET% restore Project.sln" echo "Building solution : Project.sln" script { scanner = tool name: 'NewSonarScanner', type: 'hudson.plugins.sonar.MsBuildSQRunnerInstallation' props = readProperties text: '${res}' withSonarQubeEnv('DefaultSonart') { bat "${scanner}\\SonarQube.Scanner.MSBuild.exe begin /k:Project /n:Project /v:${props.PackageVersion} /d:sonar.host.url=%SONAR_HOST_URL% /d:sonar.login=%SONAR_AUTH_TOKEN% /d:sonar.cs.nunit.reportsPaths=\"NTestResult.xml\" /d:sonar.cs.opencover.reportsPaths=\"opencover.xml\" /d:sonar.verbose=true" bat "\"${tool name: 'DefaultMSBuild', type: 'msbuild'}\"\\msbuild.exe Project.sln /m /target:clean,build /p:Configuration=Release" //;VisualStudioVersion=12.0 nunitReturn = bat returnStatus: true, script: "%OPENCOVER% -output:\"%WORKSPACE%\\opencover.xml\" -returntargetcode -register:user -target:\"%NUNIT%\" -targetargs:\"%WORKSPACE%\\Project.Tests\\bin\\Release\\Project.Tests.dll -v --result=NTestResult.xml;format=nunit3 --work=%WORKSPACE%\" " bat "${scanner}\\SonarQube.Scanner.MSBuild.exe end" } } } } stage('Positive result') { when { expression { nunitReturn == 0 } } steps { echo "Archiving Project" archiveArtifacts artifacts: '**/bin/Release/**', onlyIfSuccessful: true bat "%NUGET% pack Project\\Project.csproj -Prop Configuration=Release" bat "%NUGET% push Project\\Project.${props.PackageVersion}.nupkg -s %REPOTESTAUTO% ${key}" } } stage('Negative result'){ when { expression { nunitReturn > 0 } } steps { script { currentBuild.result = "UNSTABLE" } } } } post { failure { mail(from: "a...@test.com", to: "d...@test.com", subject: "Error in ${env.JOB_NAME}", body: "See at ${env.BUILD_URL}") } unstable { mail(from: "a...@test.com", to: "d...@test.com", subject: "Test failed in ${env.JOB_NAME}", body: "See at ${env.BUILD_URL}") } } options { // For example, we'd like to make sure we only keep 10 builds at a time, so // we don't fill up our storage! buildDiscarder(logRotator(numToKeepStr:'20')) timeout(time: 60, unit: 'MINUTES') } } the script: param([Parameter(Mandatory=$true)][string]$projectDir) $packageVersion = '' Write-Output "Executed=True" Write-Output "PropFile=:$env:WORKSPACE\\$projectDir\\Properties\\AssemblyInfo.cs'" $content = Get-Content ($env:WORKSPACE + '\\' + $projectDir + '\\Properties\\AssemblyInfo.cs'); foreach ($line in $content) { if ($line -match '\[assembly: AssemblyVersion\("((\d+)\.?(\d*)\.?(\d*)?[\.-]?([\d\*]*)?([a-zA-Z]*)?(\d*?))"\)\]') { Write-Output "AssemblyFullVersion=$($Matches[1])" Write-Output "AssemblyVersion=$($Matches[2]).$($Matches[3]).$($Matches[4])" Write-Output "AssemblyMajor=$($Matches[2])" Write-Output "AssemblyMinor=$($Matches[3])" Write-Output "AssemblyRevision=$($Matches[4])" Write-Output "AssemblyBuild=$($Matches[5])" Write-Output "AssemblySuffix=$($Matches[6])" Write-Output "AssemblyNumber=$($Matches[7])" if ($packageVersion -eq ''){ $packageVersion = $Matches[1]; } } elseif ($line -match '\[assembly: AssemblyInformationalVersion\("((\d+)\.?(\d*)\.?(\d*)?[\.-]?([\d\*]*)?([a-zA-Z]*)?(\d*?))"\)\]') { Write-Output "AssemblyInfoFullVersion=$($Matches[1])" Write-Output "AssemblyInfoVersion=$($Matches[2]).$($Matches[3]).$($Matches[4])" Write-Output "AssemblyInfoMajor=$($Matches[2])" Write-Output
Error with stash command in jenkins pipeline
Hi, i'm having an error while trying to stash some files to use in later steps. I need to execute some load tests with gatling, in parallel on differente nodes. this is the pipeline i use: pipeline { agent none parameters { string(defaultValue: '1', description: 'Number of users to simulate per single executor', name: 'users') string(defaultValue: 'http://10.150.20.117', description: 'Base url to test against', name: 'baseUrl') } stages { stage('Prepare'){ agent any steps { stash 'app' } } stage('Build') { steps { parallel( "one":{ node('test1') { unstash 'app' withMaven(globalMavenSettingsConfig: 'e0fb8527-8536-49dc-bfbd-ac98b5e85c2e', jdk: 'Default', maven: 'defaultMaven') { bat "mvn gatling:execute -e -X -Dgatling.simulationClass=it.test.prod.LoadSimulation -DloadUsers=${params.users} -DbaseUrl=${params.baseUrl}" } gatlingArchive() } }, "two":{ node('test2') { unstash 'app' withMaven(globalMavenSettingsConfig: 'e0fb8527-8536-49dc-bfbd-ac98b5e85c2e', jdk: 'Default', maven: 'defaultMaven') { bat "mvn gatling:execute -e -X -Dgatling.simulationClass=it.test.prod.LoadSimulation -DloadUsers=${params.users} -DbaseUrl=${params.baseUrl}" } gatlingArchive() } }, "three":{ node('test3') { unstash 'app' withMaven(globalMavenSettingsConfig: 'e0fb8527-8536-49dc-bfbd-ac98b5e85c2e', jdk: 'Default', maven: 'defaultMaven') { bat "mvn gatling:execute -e -X -Dgatling.simulationClass=it.test.prod.LoadSimulation -DloadUsers=${params.users} -DbaseUrl=${params.baseUrl}" } gatlingArchive() } }, "four":{ node('test4') { unstash 'app' withMaven(globalMavenSettingsConfig: 'e0fb8527-8536-49dc-bfbd-ac98b5e85c2e', jdk: 'Default', maven: 'defaultMaven') { bat "mvn gatling:execute -e -X -Dgatling.simulationClass=it.test.prod.LoadSimulation -DloadUsers=${params.users} -DbaseUrl=${params.baseUrl}" } gatlingArchive() } }, "five":{ node('test5') { unstash 'app' withMaven(globalMavenSettingsConfig: 'e0fb8527-8536-49dc-bfbd-ac98b5e85c2e', jdk: 'Default', maven: 'defaultMaven') { bat "mvn gatling:execute -e -X -Dgatling.simulationClass=it.test.prod.LoadSimulation -DloadUsers=${params.users} -DbaseUrl=${params.baseUrl}" } gatlingArchive() } } ) } } } options { buildDiscarder(logRotator(numToKeepStr:'10')) } } But at the stash step i always get an error: remote file operation failed: R:\jenkins\workspace\LoadTests\Simulation at hudson.remoting.Channel@168120a:Channel to /10.150.33.60: java.io.IOException: Remote call on Channel to /10.150.33.60 failed what could it be? -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/84ec4ed6-d1e9-4eca-ba98-e022efe33c61%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.