Continuous deployment gitlab - gitlab

Line of my .gitlab-ci.yml
IID=$(curl --verbose --request GET --header "Content-Type: application/json" --header "PRIVATE-TOKEN: ${CI_PUSH_TOKEN}" ${APP_REPO_URL}/merge_requests?author_id=xxxxxxxx\&search=${CI_COMMIT_SHORT_SHA} | jq '.[0].iid')
output jq: error (at :0): Cannot index object with number

Please refer to the documentation on Merge requests API and How to use the API to construct a properly formed cURL request with GitLab API before piping the result into jq.
There are a few things going on with your query.
First of all, according to the documentation, the /merge_requests endpoint will
Get all merge requests the authenticated user has access to.
This means that APP_REPO_URL needs to be the GitLab instance URL followed by /api/v4 and not the URL of the specific project.
curl "https://gitlab.example.com/api/v4/merge_requests"
If you need all merge requests for a given project, then you can use
curl "https://gitlab.example.com/api/v4/projects/:id/merge_requests"
where :id is the id of your project. See more at List project merge requests
Then, the search attribute is expecting either a title or a description and not a commit SHA:
Search merge requests against their title and description

Related

Limit sharepoint search API results to some geo locations

In a multi geo environment I would like to execute a SharePoint REST API search and limit it to some geo locations only as described in the microsoft multi geo documentation. I have tried the GET as well as POST requests, but all settings in my MultiGeoSearchConfiguration are ignored, I am always getting the full result list from all geo locations.
What am I doing wrong here? Is it maybe the missing sourceId that I have now idea of where to find?
curl --location -g --request GET 'https://<mydev>.sharepoint.com/_api/search/query?querytext=%27test%27&ClientType=%27cb991e32-6ce4-4e98-a91b-4eea9a874962%27&Properties=%27EnableMultiGeoSearch:true,%20MultiGeoSearchConfiguration:[{DataLocation\:%22EUR%22\,Endpoint\:%22https\://<mydev>EUR.sharepoint.com%22}]%27' --header 'Accept: application/json' --header 'Authorization: Bearer ...'
(<mydev> is exchanged for my real sharepoint of course)
In your API request, you have the EnableMultiGeoSearch:true and according to the documentation provided, it mentions that if this parameter is set to true, "the query shall be fanned out to the indexes of other geo locations of the multi-geo tenant", have you tried setting this value to false?

Automatically close outdated GitLab merge request

Is there any option to automatically close GitLab merge request after 1 day?
Manually close all the merge requests is not an option since there are many each day.
Thanks in advance
You can create a custom script that uses GitLab API either directly or via client
You'll need to generate private token with Scope: api
Example
Fetch Merge Requests updated before a specific date:
$ PRIVATE_TOKEN=****
$ curl -s -X GET -H "PRIVATE-TOKEN: $PRIVATE_TOKEN" \
"https://gitlab.com/api/v4/merge_requests?state=opened&view=simple&updated_before=2020-02-01T14:09:18.679Z" |\
jq '.[].id'
34520388
33038903
20988416
(put your token instead of ****)
Call Update request for each id in a loop, specifying state_event=close

Get programmingLanguage and topic for Github repo via API

How can I get the repo-language and topic for a Github Repo through the REST API. I looked at the documentation under - https://developer.github.com/v3/ , but could not get an answer.
Just found one way to do the search for topics as follows. Of course it needs a custom media type at moment.
From the documentation:
curl -H "Authentication: token TOKEN" \
-H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/search/repositories?q=topic:ruby+topic:rails
For the language, it is simply the URL like :
https://api.github.com/repos/postgres/pgadmin4/languages

Gitlab API adding members to a project

I'm experiencing errors when trying to add users to a Gitlab project using the Gitlab API. I'm using Gitlab version 8.11.0 on CentOS 6.8 and I'm not sure if it is a bug or something I am doing wrong.
The following works fine and gives me a list of project members:
curl --header "PRIVATE-TOKEN: top_secret" "https://thegitlabserver.com/api/v3/projects/1/members"
but when trying to add a members with the following, I get an error message:
curl --request POST --header "PRIVATE-TOKEN: top_secret" "https://thegitlabserver.com/api/v3/projects/1/members/myusername?access_level=30"
{"error":"405 Not Allowed"}
Using the web interface I am able to add the user to the project.
It looks like the Gitlab API documentation was incorrect.
As it's a create action, you should send both the user ID and access levels as named parameters (like you would for creating any other resource).
So something like: https://thegitlabserver.com/api/v3/projects/1/members/?user_id=299&access_level=40

Square Connect can't subscribe to webhook notifications

I am following the instructions here on setting up webhook notifications for Square payments. But when I execute the curl statement in step 5 to subscribe to my own merchant's payment notifications, I get the response:
{"type":"bad_request","message":"Request body is not an array of event types"}
The curl statement is
curl -X PUT -H "Authorization: Bearer MY_ACCESS_TOKEN" -d '{"event_types": ["PAYMENT_UPDATED"]}' https://connect.squareup.com/v1/me/webhooks
Did they update the event type names? I can't find any other documentation on webhooks.
Whoops! Thanks for catching this error in the blog post, which I have now corrected. The format of the curl previously shown in step 5 had two errors:
The request body should simply have been the array of desired event types, such as:
["PAYMENT_UPDATED"]
With no JSON object surrounding it. The correct format is also shown in the API documentation.
The request was missing a Content-Type: application/json header. All requests to Connect API endpoints require this header.
The correct request looks like this, with your personal access token substituted where indicated:
curl -X PUT -H "Authorization: Bearer PERSONAL_ACCESS_TOKEN" -H "Content-Type: application/json" -d "[\"PAYMENT_UPDATED\"]" https://connect.squareup.com/v1/me/webhooks

Resources