How to add commits through CICD pipeline

I like to add commit message to my master brach when i create new release.
With that commit message will trigger nightly deployment process.

When i try the below commad

Pre-depoyment:

stage: CodeCommit

rules:

- if: $CI_COMMIT_TAG

script:

- echo $CI_COMMIT_TAG

- |

  curl --request POST --header 'PRIVATE-TOKEN: ${CI_JOB_TOKEN}' --data '{"branch": "master", "commit_message": "RedyForDeploy"}' \

       "https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fproject%2Erb"

Powershell Output:

$ curl --request POST --header ‘PRIVATE-TOKEN: ${CI_JOB_TOKEN}’ --data ‘{“branch”: “master”, “commit_message”: “create a new file”}’ \ # collapsed multi-line command

Invoke-WebRequest : A positional parameter cannot be found that accepts argument ‘POST’.

At C:\Windows\TEMP\build_script078740762\script.ps1:245 char:1

  • curl --request POST --header ‘PRIVATE-TOKEN: ${CI_JOB_TOKEN}’ --data …
    )+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  • CategoryInfo : InvalidArgument: (:slight_smile: [Invoke-WebRequest], ParameterBindingException

) + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fproject.rb

"content" is mandatory for Repository files API | GitLab

You can use Commits API | GitLab if you want to make an empty commit

$headers = @{
  "PRIVATE-TOKEN" = "*****************"
}
$body = @{
  "branch" = "main"
  "commit_message" = "this is a commit"
  "actions" = ""
}
Invoke-RestMethod -Verbose -Header $headers -ContentType 'application/json' -Body ($body|ConvertTo-Json) -Method Post -Uri "https://gitlab.com/api/v4/projects/****/repository/commits"