jenkins pipeline: multiline shell commands with pipe

前端 未结 3 497
青春惊慌失措
青春惊慌失措 2021-01-07 16:51

I am trying to create a Jenkins pipeline where I need to execute multiple shell commands and use the result of one command in the next command or so. I found that wrapping t

3条回答
  •  半阙折子戏
    2021-01-07 17:09

    I split the commands with &&

    node {
      FOO = world
      stage('Preparation') { // for display purposes
          sh "ls -a && pwd && echo ${FOO}"
      }
    }
    

    The example outputs: - ls -a (the files in your workspace - pwd (location workspace) - echo world

提交回复
热议问题