I use following script to get the description of a group in GitLab.
Script:
#! /bin/bash
GIT_API="https://git.xxxxxxxxxx.lk/api/v4"
GIT_TOKEN="xxxxxxxxxxxx"
curl -sS --request GET --header "PRIVATE-TOKEN: $GIT_TOKEN" "$GIT_API/groups/1079" | jq -r ".[] .description"
But it outputs following error:
jq: error (at <stdin>:0): Cannot index number with string "description"
How to solve this problem.
curl output:
{
"id": 1079,
"web_url": "https://git.xxxxxxxxxx.lk/groups/testdevops",
"name": "testdevops20",
"path": "testdevops",
"description": "Test_1",
"visibility": "private",
"share_with_group_lock": false,
"require_two_factor_authentication": false,
"two_factor_grace_period": 48,
"project_creation_level": "developer",
"auto_devops_enabled": null,
"subgroup_creation_level": "maintainer",
"emails_disabled": null,
"mentions_disabled": null,
"lfs_enabled": true,
"default_branch_protection": 1,
"avatar_url": null,
"request_access_enabled": true,
"full_name": "testdevops20",
"full_path": "testdevops",
"created_at": "2021-05-31T04:56:28.467Z",
"parent_id": null,
"shared_with_groups": [],
"runners_token": "Dw_LPVsbeChD6s6n1wRy",
"projects": []
}
Fix the script as follow:
#! /bin/bash
GIT_API="https://git.xxxxxxxxxx.lk/api/v4"
GIT_TOKEN="xxxxxxxxxxxx"
curl -sS --request GET --header "PRIVATE-TOKEN: $GIT_TOKEN" "$GIT_API/groups/1079" | jq -r ".description"
The jq
command works if written as jq -r ".description"
.