简体   繁体   English

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

[英]shell script returning not found on jenkins master using pipeline as code

I am new to jenkins and trying to write a pipeline.我是 jenkins 的新手,正在尝试编写管道。 Everything is working when run with jobs, but facing issue with pipeline.运行作业时一切正常,但面临管道问题。 My script which should run after checking out from github returns file not found.我应该在从 github 签出后运行的脚本返回找不到文件。 Could anyone help please.任何人都可以请帮忙。 Attached is the image of the log.附上日志图片。 https://i.stack.imgur.com/LuxGn.png Below is the code sample I am trying to execute. 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. check the file script is here with command sh 'ls' just after the git step.在 git 步骤之后使用命令 sh 'ls' 检查文件脚本在这里。 generally I would recommend not to use git step but checkout instead, it is more powerful and more reliable通常我会建议不要使用 git step 而是使用 checkout ,它更强大,更可靠
    checkout([
         $class: 'GitSCM',
         branches: scm.branches,
         extensions: scm.extensions,
         userRemoteConfigs: [[
             url: 'https://github.com/rk280392/pipeline_scripts.git'
         ]]
    ])
  1. is your script executable?你的脚本是可执行的吗? you could use chmod +x puppet_master.sh before running it with dot slash as prefix ./puppet_master.sh您可以使用chmod +x puppet_master.sh在以点斜杠作为前缀运行它之前使用./puppet_master.sh
sh 'sh puppet_master.sh'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM