Team,
I am unable to substitute values inside json(myjson) to use in curl command. any hint?
JENKINS_USERNAME="svc-user"
JENKINS_USER_TOKEN="xxxx"
JENKINS_INSTANCE_FQDN="sham.blsm.comp.com"
INSTANCE="test-verify"
CREDENTIAL_ID_NAME="test"
USERNAME_KEY="tests"
USER_PASSWORD_KEY="testst"
ID_DESCRIPTION="asdfasdfasdf"
myjson=\''{
"credentials": {
"scope": "GLOBAL",
"id": "'"${CREDENTIAL_ID_NAME}"'",
"username": "'"${USERNAME_KEY}"'",
"password": "'"${USER_PASSWORD_KEY}"'",
"description": "'"${ID_DESCRIPTION}"'",
"\$class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
}
}'\'
curl -X POST https://${JENKINS_USERNAME}:${JENKINS_USER_TOKEN}@${JENKINS_INSTANCE_FQDN}/${JENKINS_INSTANCE}/credentials/store/system/domain/_/createCredentials \
--data-urlencode ${myjson}
output
curl -X POST https://${JENKINS_USERNAME}:${JENKINS_USER_TOKEN}@${JENKINS_INSTANCE_FQDN}/${JENKINS_INSTANCE}/credentials/store/system/domain/_/createCredentials \
--data-urlencode ${myjson}
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched brace in URL position 1:
{
^
below answer did not help me Bash variable substitution in a JSON string