« Back to Index

Multiline Curl PUT’ing of data with no extra processing (thanks to –data-binary flag). We also use @ with a hyphen, so @- (the hyphen indicates input from stdin)

View original Gist on GitHub

Multiline Curl PUT’ing of data with no extra processing.sh

curl -E $DEV_CERT_PEM https://api.our-service.com/component/component-name/configuration --header 'Content-Type: application/json' --request PUT --data-binary @- <<BODY
[
    {
        "key": "git_ssh_private_key",
        "value": "$(cat pri.key)",
        "secure": true
    },
    {
        "key": "git_ssh_public_key",
        "value": "$(cat pub.key)",
        "secure": true
    },
    {
        "key": "jenkins_master_internal_hostname",
        "value": "foo.bar.jenkins.baz.qux.my-domain.com"
    },
    {
        "key": "cloudwatch_log_group_name",
        "value": "live-foo-bar-jenkins-baz-main-JenkinsAgentsLogGroup-qux"
    },
    {
        "key": "docker_registry_hostname",
        "value": "https://jenkins.foobar.my-domain.com"
    }
]
BODY