I would like to modify deployment environments within a repo using the API.
The most appropriate method is:
/2.0/repositories/{workspace}/{repo_slug}/environments/{environment_uuid}/changes/
However the documentation does not specify a body to POST. How do we use this API call? Any examples what params to place after "changes"?
Worked around guessing a payload by snooping Network traffic in browser console, when performing the same action on the bitbucket UI.
API docs are not 100% complete without some of this guess work
I am having the same issue. Could you clue me in on the required parameters to include in the post body?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
nvm I found the same info in network tab
for anyone else looking try this post body with curl
`-d '{"change": {"name": "Test-42"}}`
It is still unclear to me which attributes of the deployment can be changed via the REST API. I can update the name but attempts to modify other params have given me the following error:
`{"key": "deploy-service.environment.change-not-supported", "message": "The requested change is not allowed.", "arguments": {}}`
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Heather Young A late - but nonetheless BIG - "Thank You" for posting this! I went almost insane with this api-call not doing what it is supposed to.
I just wonder: How can that still not be properly documented by Atlassian meanwhile? I tried several resources like OpenApi/Swagger., the official Api-Reference and some more until i finally found this post several hours later.
By the way: It seems that (meanwhile?) other environment-parameters can also be updated. At least it worked for me for all params that i tried so far.
In my script, i now detect if an environment already exists -> if yes, i just wrap the body-json (that i use for the create-api otherwise) in an element called "change".
For me the "restrictions" block was the most important to update, besides maybe the name.
If anyone is interested, here is that specific part of my (working) Powershell script:
# Get environment uuid if env. already exists
$env_uuid = ($existing_environments | Where-Object {$_.name -eq "Test-Env"}).uuid | Get-Unique
# Set payload
$body = @{
type = "deployment_environment"
name = "Test-Env"
environment_type = @{
type = "deployment_environment_type"
name = "Test"
}
restrictions = @{
type = "deployment_restrictions_configuration§
admin_only = true
}
}
# Create or update environment
if (!$env_uuid) {
# Convert body to json
$body = $body | ConvertTo-Json -Depth 10
# Invoke Rest-Api - Create
Write-Host "Creating environment Test-Env"
Invoke-RestMethod -Method 'POST' -Uri $api_url -Authentication Bearer -Token $token -ContentType 'application/json' -Body $body | out-null
}
else
{
# If update, wrap body with element "change". Thanks to Atlassian for not documenting this properly...
$body = @{ change = $body } | ConvertTo-Json -Depth 10
# Set endpoint for update (add env. uuid)
$api_url_env = $api_url + "$env_uuid/changes/"
# Invoke Rest-Api - Update
Write-Host "Updating environment Test-Env"
Invoke-RestMethod -Method 'POST' -Uri $api_url_env -Authentication Bearer -Token $token -ContentType 'application/json' -Body $body | out-null
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The lack of where to put the branch restriction is still there today!
https://community.developer.atlassian.com/t/attempting-to-manage-bitbucket-via-terraform-and-got-some-oddities/76607
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.