【问题标题】:Command Not Found Using Jenkins Blue Ocean使用 Jenkins Blue Ocean 找不到命令
【发布时间】:2019-09-04 20:38:18
【问题描述】:

我正在尝试设置一个 Jenkins Blue Ocean 管道,以便在 PR 合并时自动构建我的 github 存储库。

我已经为 Jenkins 安装了 Go 插件,并在 Blue Ocean 的帮助下创建了以下 Jenkinsfile。一开始只是希望它非常简单 - 我有一个要运行的 shell 脚本来构建我只需要 Jenkins 在合并时运行它的程序。

pipeline {
  agent any
  stages {
    stage('Building Backend') {
      agent any
      steps {
        echo 'Using Go 1.12'
        tool(name: 'Go 1.12', type: 'go')
        echo 'Building Backend...'
        sh 'go version'
      }
    }
  }
}

上面的Jenkinsfile返回

go: command not found
script returned exit code 127

但理想情况下,我希望它能够识别 Go,因为我将运行 go build 命令的日志。我在 Jenkins 的设置中的 global tool configuration 中添加了 Go 作为工具。

【问题讨论】:

    标签: go jenkins jenkins-pipeline jenkins-plugins devops


    【解决方案1】:

    您可以尝试执行以下命令来判断 go CLL 是否存在:

    sh 'which go'
    

    【讨论】:

    • 不幸的是运行失败,returned exit code 1
    • 也许你应该给一个特定的代理而不是使用'agent any'。
    • 能否提供更多日志详细信息?
    • 这是我在脚本运行后从蓝海中得到的最多的东西。如果没有代理会是什么?
    【解决方案2】:

    Jenkins 插件不安装可执行文件。将它们视为控制器。您应该将 Go 安装到您的系统中并告诉 Jenkins Global Tool Configuration 中的可执行文件的路径。

    您可以在此处查看 Git 示例:

    【讨论】:

    猜你喜欢
    • 2019-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-27
    • 1970-01-01
    • 1970-01-01
    • 2020-04-26
    相关资源
    最近更新 更多