这里主要是注意json用单引号括起来,json内的双引号需要用反斜线\转义

pipeline {
	agent any
    stages {
      stage('TEST CURL') {
        steps {
          withCredentials([usernamePassword(credentialsId: 'technical', usernameVariable: 'username', passwordVariable: 'password')]){
                 sh '''
						curl -s -o return.json -X POST -u $username:$password -H "Content-type: text/json" --data '{\"Name\": \"ABC\", \"PASS\": \"AAA\"}' https://127.0.0.1/post
				   '''
            }
		}
      }
    }
}
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐