0

I want to create a curl command that POST a release with a description that is the result from a git command.

Curl command (working):

 curl --request POST --data "{"description": "MY git command result should be here"}" "https://gitlab.unc.nc/api/v4/projects/$APP_GITLAB_NUMBER/repository/tags/$CI_COMMIT_TAG/release"

Git command (working):

git log $(git describe --tags --abbrev=0)..HEAD --oneline

So how can I include the result of git command in the description ? As a single line command.

Tyvain
  • 2,640
  • 6
  • 36
  • 70

2 Answers2

1

Just combine them with backticks `` or $().

curl --request POST --data "{\"description\": \"`git log $(git describe --tags --abbrev=0)..HEAD --oneline`\"}" "https://gitlab.unc.nc/api/v4/projects/$APP_GITLAB_NUMBER/repository/tags/$CI_COMMIT_TAG/release"

curl --request POST --data "{\"description\": \"$(git log $(git describe --tags --abbrev=0)..HEAD --oneline)\"}" "https://gitlab.unc.nc/api/v4/projects/$APP_GITLAB_NUMBER/repository/tags/$CI_COMMIT_TAG/release"

May both OK.

Geno Chen
  • 4,916
  • 6
  • 21
  • 39
0

store the git log description in a tmp file

echo -n "description: ' >> git_desc 
git log $(git describe --tags --abbrev=0)..HEAD --oneline &>> git_desc

post data from curl

curl --request POST --data "@git_desc" "https://gitlab.unc.nc/api/v4/projects/$APP_GITLAB_NUMBER/repository/tags/$CI_COMMIT_TAG/release"
Akhil
  • 912
  • 12
  • 23
  • 1
    Nice! But a one line command is what OP is asking for. But this is a good solution too. @Tyvain check this link out [Link](https://stackoverflow.com/questions/12583930/use-pipe-for-curl-data) – clamentjohn Feb 20 '19 at 05:30