Hello to all,
I'm creating an application under powershell to update the jira plugins.
I was able to retrieve the list of plugins installed on our site and compare with the versions available on the atlassian marketplace without too much trouble.
I'm stuck mainly on sending the plugin file to jira through the UPM rest API, the request is sent to jira but I must be missing information because the UPM log returns "Failed to install app plugin_8212726077636355451_groovyrunner-6.50.0.jar"
test code for upload :
$AuthString = "{0}:{1}" -f 'name', 'password'
$AuthBytes = [System.Text.Encoding]::Ascii.GetBytes($AuthString)
$BasicCreds = [Convert]::ToBase64String($AuthBytes)
$UMPTokens = Invoke-WebRequest -Uri "https://XXXXXXX/rest/plugins/1.0/?os_authType=basic" -Method Head -Headers @{"Authorization" = "Basic $BasicCreds" }
$filePath="c:\temp\groovyrunner-6.50.0.jar"
$fileBin = [System.IO.File]::ReadAllBytes($filePath)
$boundary = [System.Guid]::NewGuid().ToString()
$LF = "`r`n"
$bodyLines = (
"--$boundary",
"Content-Disposition: form-data; name=`"plugin`"; filename=`"groovyrunner-6.50.0.jar`"",
"Content-Type: application/octet-stream$LF",
$filepath,
"--$boundary--$LF"
) -join $LF
Invoke-RestMethod -Uri "https://XXXXXXX/rest/plugins/1.0/?token=$($UMPTokens.Headers.'upm-token')" -Method Post -ContentType "multipart/form-data; boundary=`"$boundary`"" -Body $bodyLines -Headers @{"Authorization" = "Basic $BasicCreds" }
Thanking you in advance for any help you can provide