gitlab-projects-issues¶
Generate GitLab project issues and milestones statistics automatically
Table of contents
Issues access token¶
- Settings:
- Action: Add new token
- Token name:
<path/to/webhooks/project>-reporter-api
- Expiration date:
yyyy-12-31
- Select a role:
Reporter
- Select scopes:
- api: Enable
- Action: Create project access token
- Your new project access token:
- Action: Copy project access token
CI/CD webhooks project¶
-
Settings / CI/CD / Variables:
- Action: Add variable
- Visibility: Masked and hidden
- Protect variable: Enable
- Expand variable reference: Enable
- Key:
GITLAB_TOKEN
- Value:
PASTE_<path/to/webhooks/project>-reporter-api_TOKEN
- Action: Add variable
- Action: Add variable
-
Settings / Access tokens:
- Action: Add new token
- Token name:
webhook-issues
- Expiration date:
yyyy-12-31
- Select a role:
Maintainer
- Select scopes:
- api: Enable
- Action: Create project access token
- Token name:
- Your new project access token:
- Action: Copy project access token
- Action: Add new token
-
Repository sources with a
gitlab-projects-issues
CI/CD pipeline:
Webhooks / README.md
# GROUP - PATH - Webhooks
**Documentation:** <https://radiandevcore.gitlab.io/tools/gitlab-projects-issues>
Webhooks / .gitlab-ci.yml
.image-issues:
image: registry.gitlab.com/radiandevcore/tools/gitlab-projects-issues/gitlab-projects-issues:latest
variables:
# Predefined CI variables
GITLAB_TOKEN:
value: ''
description: 'GitLab private token'
ISSUES_DEFAULT_ESTIMATE:
value: '20'
description: 'Issues - Default estimated times for issues'
ISSUES_PROJECT:
value: 'group/path/to/issues'
description: 'Issues - GitLab project path with namespace'
stages:
- issues
issues:milestones:
stage: issues
extends:
- .image-issues
interruptible: true
resource_group: 'issues.milestones'
script:
# Debounce pipeline executions
- |
set +x
mkdir -p ./.cache/
touch -d '-5 minutes' ./.cache/timestamp_debounce
if [ -f ./.cache/timestamp_last ] && [ ./.cache/timestamp_last -nt ./.cache/timestamp_debounce ]; then
echo ' '
echo ' [INFO] Debouncing API access, cancelling job...'
echo ' '
exit 0
else
touch ./.cache/timestamp_last
fi
# Generate milestones statistics
- |
gitlab-projects-issues \
--milestones-statistics \
--default-estimate "${ISSUES_DEFAULT_ESTIMATE:?}" \
"${CI_SERVER_URL}/${ISSUES_PROJECT:?}"
cache:
paths:
- .cache/timestamp_last
start_in: 5 minutes
when: delayed
Issues webhook configuration¶
- Settings / Webhooks:
- Action: Add new webhook
- URL:
https://<GITLAB_DOMAIN>/api/v4/projects/<PATH%2FTO%2FWEBHOOK%2FPROJECT>/pipeline?ref=<BRANCH>
- Action: Add custom headers
- Header name:
PRIVATE-TOKEN
- Header value:
PASTE_webhook-issues_TOKEN
- Header name:
- Name:
gitlab-projects-issues
- Trigger:
- Issues events: Enable
- Enable SSL verification: Enable
- Action: Add webhook
- URL:
- Action: Test (
gitlab-projects-issues
) / Issue events
- Action: Add new webhook