首页 > 解决方案 > 如何在一行上使用 CURL 传递数据

问题描述

您好,我想使用 API 方法通过 curl 显示 jenkins 构建状态,如下所述:https ://developer.atlassian.com/server/bitbucket/how-tos/updating-build-status-for-commits/

组装:

curl -u username:'password' -H "Content-Type: application/json" -X POST https://tools.my.repo.com/bitbucket/rest/build-status/1.0/commits/620d293ed88412e45c58aae537b8765be2e8d148 -d @build0.json`

我的构建 json 包含:

{
        "state": "SUCCESSFUL",
        "key": "8",
        "name": "feature/branch",
        "url": "https://my.jenkins.placeholder/job/Plugintest/",
        "description": "Changes by Umbert Eco"
}

我需要把它放在一条线上……有可能吗?

标签: jsonjenkinsdevopsbitbucket-api

解决方案


是的!!尝试以这种方式构建卷曲

curl -u username:password -H "Content-Type: application/json" -X POST https://tools.my.repo.com/bitbucket/rest/build-status/1.0/commits/620d293ed88412e45c58aae537b8765be2e8d148 -d '{\"state\": \"SUCCESSFUL\",\"key\": \"8\",\"name\": \"feature/branch\",\"url\": \"https://my.jenkins.placeholder/job/Plugintest\",\"description\": \"Changes by Umbert Eco\"}'

推荐阅读