Mantis Versions:
Operating Systems (all supported by PowerShell Core):
- Mac OS X
- Windows
- Linux
Download and extract Mantis PowerShell Release
Create API Token as per the following article.
Load Mantis PowerShell module in an open PowerShell terminal:
Import-Module ./mantis.psm1
Create ~/.mantis.companyname.json with contents like the one below including the appropriate URL and logical
name for the instance.
Example for authenticated instance:
{
"uri": "https://companyname.com/mantisbt/",
"token": "YjQlU7OI0D..........sWC1vGaAuq3Q"
}Example for anonymous access
{
"uri": "https://companyname.com/mantisbt/"
}Select the instance for all future commands:
Use-MantisInstance companyname
Note that the selected instance will be persisted on disk, hence, it will persist across PowerShell
restarts. This is done by copying .mantis.company.json to .mantis.json. So if the configuration
is changed, re-run the command Use-MantisInstance.
Get-MantisVersion
Get-MantisUser -me
Get projects accessible to logged in user:
Get-MantisProject
$issue = New-MantisIssue -summary "summary" -description "desc" -handler "vboctor" -project "mantisbt" -category "ui" -version "2.8.0" -priorty "high"
$issue | Add-MantisIssue
Sample File (sample.csv)
"project", "category", "summary", "description"
"mantisbt", "ui", "test csv 1", "test csv 1"
"mantisbt", "ui", "test csv 2", "test csv 2"
Importing the file
Import-Csv -Path ./sample.csv | New-MantisIssue | Add-MantisIssue
$issue = New-MantisIssue -summary "summary" -description "desc" -project "mantisbt" -category "ui" -customFields @{ "The City" = "Seattle", "Root Cause" = "Code Bug" }
$issue | Add-MantisIssue
Get-MantisIssue 1
@(1, 2, 3) | Get-MantisIssue
$issue = Get-MantisIssue 1
$issue.history
Get the first page of issues with default page size:
Get-MantisIssue
Get a specific page and page size:
Get-MantisIssue -page 5 -pageSize 50
Assign issue 1 to vboctor
New-MantisIssue -id 1 -handler "vboctor" -status "assigned" | Edit-MantisIssue
Assign a set of issues to vboctor
@(1, 5, 10) | New-MantisIssue -handler "vboctor" -status "assigned" | Edit-MantisIssue
Assign a batch of issues to vboctor
Get-MantisIssue -page 1 -pageSize 5 | New-MantisIssue -handler "vboctor" -status "assigned" | Edit-MantisIssue
Delete an issue via its id
Remove-MantisIssue 1
Delete an issue via ids on pipeline
@(1, 2, 3) | Remove-MantisIssue
Delete an issue via issue on pipeline
Get-MantisIssue 1 | Remove-MantisIssue
Get-MantisIssue 1 | ConvertTo-Json -Depth 100 | Out-File issue000001.json
Retrieve a single config option:
Get-MantisConfig webmaster_email
Retrieve multiple config options in one call to Mantis:
@("status_enum_string", "priority_enum_string") | Get-MantisConfig
Retrieve multiple config options and dumping them to an config.json file:
@("status_enum_string", "priority_enum_string") | Get-MantisConfig | ConvertTo-Json -Depth 100 | Out-File config.json
Get a single string
Get-MantisString login_anonymously
Get multiple strings in one call to Mantis
@("login_anonymously", "anonymous") | Get-MantisString
Get multiple strings and dump them to a json file
@("login_anonymously", "anonymous") | Get-MantisString | ConvertTo-Json -Depth 100 | Out-File lang.json
