使用管道作为代码的jenkins master上找不到shell脚本返回

时间:2020-01-21 14:00:37

标签: shell jenkins jenkins-pipeline pipeline

我是jenkins的新手,正在尝试编写管道。作业运行时一切正常,但面临管道问题。我的脚本从github签出后应该运行,返回的文件未找到。任何人都可以帮忙。附件是日志的图像。 https://i.stack.imgur.com/LuxGn.png 下面是我尝试执行的代码示例。

 stage('puppet master config checkout') {
        steps {
            echo "cloning github"
            git "https://github.com/rk280392/pipeline_scripts.git"
        }

    }
     stage('puppet master config build') { 
        steps {
            echo "running puppet master script"
            sh "puppet_master.sh"
        }

    }

1 个答案:

答案 0 :(得分:0)

  1. 在git步骤之后,使用命令sh'ls'检查文件脚本是否在此处。 通常,我建议不要使用git step,而是使用checkout,它更强大,更可靠
    checkout([
         $class: 'GitSCM',
         branches: scm.branches,
         extensions: scm.extensions,
         userRemoteConfigs: [[
             url: 'https://github.com/rk280392/pipeline_scripts.git'
         ]]
    ])
  1. 您的脚本可执行吗?您可以在以点斜杠作为前缀chmod +x puppet_master.sh运行它之前使用./puppet_master.sh
sh 'sh puppet_master.sh'