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

前端 未结 6 1260
清歌不尽
清歌不尽 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 20:53

    I am also struggling with the usage of pipe inside my jenkins pipeline but as a side note, if you want a simple way to extract the version of a maven pom, here's a very clean one I found in another post and that I'm using :

    stage('Preparation') {
     version = getVersion()
     print "version : " + version
    }
    def getVersion() {
      def matcher = readFile('pom.xml') =~ '(.+)'
      matcher ? matcher[0][1] : null
    }
    

    gives you :

    [Pipeline] echo
    releaseVersion : 0.1.24
    [Pipeline] sh
    

提交回复
热议问题