Last active
November 19, 2019 21:47
-
-
Save jovemfelix/b8c7282361250002c7a813d7f6aad97c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GITLAB_TOKEN='nuXXPQyGMmCNwWnsVlm3' | |
GITLAB_BASE_URL='https://www.example.com.br/repo' | |
## <YOUR-NAMESPACE>%2F<YOUR-PROJECT-NAME> --> %2F is / url-encoded | |
GITLAB_PROJECT_NAME='codigo%2Fmoodle-php' | |
# get project by name | |
PROJECT_ID=$(curl -XGET -H "Content-Type: application/json" \ | |
-H "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \ | |
${GITLAB_BASE_URL}/api/v4/projects/${GITLAB_PROJECT_NAME} | jq '.id') | |
echo ${PROJECT_ID} | |
# list webhooks | |
curl -XGET -H "Content-Type: application/json" \ | |
-H "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \ | |
${GITLAB_BASE_URL}/api/v4/projects/${GITLAB_PROJECT_NAME}/hooks | jq | |
# create webhook | |
curl -H "Content-Type: application/json" \ | |
-H "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \ | |
-XPOST -d '{"url":"http://my-url-to-be-called-when-event-occur","push_events":"true", "enable_ssl_verification": "false"}' \ | |
${GITLAB_BASE_URL}/api/v4/projects/${GITLAB_PROJECT_NAME}/hooks | jq | |
# API Reference | |
https://docs.gitlab.com/ce/api/projects.html#get-single-project |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment