Last active
October 12, 2018 16:55
-
-
Save skalahonza/56cdbda2af73d51a2eb5ce796b7730ae to your computer and use it in GitHub Desktop.
Gitlab timetracking and issues loading (powershell script)
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
$apiKey = "your api key" | |
$gitlabhost = "https://gitlab.yourcompany.com" | |
$headers = @{ | |
'PRIVATE-TOKEN'="$apiKey" | |
"Accept-Charset" = "utf-8" | |
"Accept" = "application/json" | |
"Content-Type" = "application/json; charset=utf-8" | |
} | |
function Get-GitLabIssues($milestone,$projectId){ | |
# time tracking and estimates are in seconds | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # solve ssl tunel problem | |
$result = Invoke-RestMethod -Method Get -Headers $headers -Uri "$gitlabhost/api/v4/projects/$projectId/issues?scope=all&milestone=$milestone"; | |
return $result; | |
} | |
function Get-GitLabTimeTracking($milestone, $projectId){ | |
Get-GitLabIssues -projectId $projectId -milestone $milestone | select id, title, @{ Name = 'Assignee'; Expression = {$_.assignee.name}}, @{ Name = 'Time spent (h)'; Expression = {$_.time_stats.total_time_spent/60/60}}, @{ Name = 'Time estimate (h)'; Expression = {$_.time_stats.time_estimate/60/60}} | |
# you can export to csv with ↓ | |
# | Export-Csv -Path "test.csv" -Encoding Default -NoTypeInformation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment