简体   繁体   中英

curl: (3) [globbing] unmatched brace at pos 2

I keep receiving this error: curl: (3) [globbing] unmatched brace at pos 2 and I don't even understand where is "pos 2" Although strangely I don't have the same problem when I do that from bash. I run that code in Jenkins pipeline. That is why you see sh '''' wrapper

sh '''
    curl  -u ${GIT_USERNAME}:${GIT_PASSWORD} -H "Content-Type: application/json" -X POST https://tools.company.my.com/bitbucket/rest/build-status/1.0/commits/$GIT_COMMIT --data-binary @- <<BODY \
            {
              "state": "SUCCESSFUL",
              "key": "$JOB_BASE_NAME",
              "name": "$BUILD_TAG",
              "url": "$BUILD_URL",
              "description": "change"
            }
            BODY
               '''   

Assuming there is no single quote in ${GIT_PASSWORD}:

sh -c "curl -u '${GIT_USERNAME}:${GIT_PASSWORD}'\
            -H 'Content-Type: application/json'\
            -X POST 'https://tools.company.my.com/bitbucket/rest/build-status/1.0/commits/$GIT_COMMIT'\
            --data-binary @-" << BODY
            {
              "state": "SUCCESSFUL",
              "key": "$JOB_BASE_NAME",
              "name": "$BUILD_TAG",
              "url": "$BUILD_URL",
              "description": "change"
            }
BODY

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM