Jenkins pipeline sh does not seem to respect pipe in shell command

前端 未结 6 1258
清歌不尽
清歌不尽 2020-12-15 20:29

I am using a Jenkinsfile in a pipeline on version 2.32.2.

For various reasons I want to extract the version string from the pom. I was hoping I wouldn\'t have to a

6条回答
  •  [愿得一人]
    2020-12-15 21:11

    If your environment allows it, I've found a simple solution to this problem to be to place your script containing pipes into a file, and then run that with sh, like so:

    script.sh:

    #!/bin/sh
    kubectl exec --container bla -i $(kubectl get pods | awk '/foo-/{ print $1 }') -- php /code/dostuff
    

    Jenkinsfile:

    stage('Run script with pipes') {
      steps {
        sh "./script.sh"
      }
    }
    

提交回复
热议问题