*I'm trying to run this pipeline script:* def getAgentMachine() { def agentMachine switch(params.agentMachine) { case "cloud1": agentMachine = "cloud1"; break case "mac1": agentMachine = "mac1"; break } return agentMachine }
def getOs(){ if (agentMachine.contains("mac")) { return "macosx" } else { return "windows" } } def printWorkingDirectory(){ String os = getOs(); if (os == 'windows'){ bat 'chdir' } else { sh 'pwd' } } def listFiles(){ String os = getOs(); if (os == 'windows'){ bat 'dir' } else { sh 'ls -l' } } def cmd_exec(command) { return bat(returnStdout: true, script: "${command}").trim() } def getProjectName() { return params.projectName } pipeline { agent { // label params.agentMachine == "any" ? "" : params.agentMachine label "mac1" } parameters { string( name: "agentMachine", defaultValue: "mac1", description: "Select the agent machine to run the project on" ) string( name: "projectName", defaultValue: "Auto_MC", description: "Provide the project to copy" ) } stages { stage("Start services") { steps { sh('pwsh -version') echo "Agent machine is [${getAgentMachine()}]" echo "OS is [${getOs()}]" echo "1. Project name is [${getProjectName()}]" script { projectNameToCopy = getProjectName().trim() } powershell """ write-host (Get-Item .).FullName -fore green write-host "2. Project name: " ${projectNameToCopy} -fore green """ } } } } *The output is:* Started by user Andrei Suslov [Pipeline] Start of Pipeline [Pipeline] node Running on a51-wg7-mac1 in /Library/Automation/slave/jenkins/workspace/123 [Pipeline] { [Pipeline] stage [Pipeline] { (Start services) [Pipeline] sh sh: sh: command not found wrapper script does not seem to be touching the log file in /Library/Automation/slave/jenkins/workspace/123@tmp/durable-b0720b96 (JENKINS-48300: if on an extremely laggy filesystem, consider -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.HEARTBEAT_CHECK_INTERVAL=86400) [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code -1 Finished: FAILURE I tried to look for a solution: people suggest to delete PATH variable (it's not there already, so I guess someone else deleted it) and introduce PATH+EXTRA variable, but I don't know what value to assign to it... -- 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/ef343a38-01e3-465c-8e74-04026c5c4d22n%40googlegroups.com.