2019-09-03 20:34
浏览 272

使用Jenkins Blue Ocean找不到命令

I am trying to set up a Jenkins Blue Ocean pipeline to auto-build my github repo on a PR merge.

I've installed the Go plugins for Jenkins and created the following Jenkinsfile with the help of Blue Ocean. Just wanted it to be very simple at first - I have a shell script to run that will build the program I just need Jenkins to run it on merge.

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'

The above Jenkinsfile returns

go: command not found
script returned exit code 127

but ideally I want it to recognize Go since I will be running a log of go build commands. I added Go as a tool in global tool configuration in the settings of Jenkins.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanjian9148
    duanjian9148 2019-09-04 00:14

    You can try to execute below command to figure out whether go CLL does exist:

    sh 'which go'
    点赞 评论
  • duangu9666
    duangu9666 2019-09-04 12:38

    Jenkins plugins do not install executables. Think them as controllers. You should install Go into your system and tell Jenkins that the path of the executable in Global Tool Configuration.

    You can see an example of Git here:

    Example of Global Tool Configuration

    点赞 评论