Description
How to reproduce:
1) navigate to an agent information page (in my case that's a remote agent)
2) "Dedicate Agent"
3) select "Build Job" on the left and an arbitrary job on the right
4) notice that the job appears below the combo-boxes with an "x" mark allowing you to remove it
5) click "Add" and go back to agent information page
6) click "Dedicate Agent"
7) the job you've just added is not listed there anymore and there's seemingly no way to "undedicate" the agent
Workaround
- Backup Bamboo (precaution)
- Stop Bamboo
- Run the following SQL query to delete assignments that are not pointed to existing entities:
delete from AGENT_ASSIGNMENT where EXECUTABLE_TYPE in ('PLAN', 'JOB') and EXECUTABLE_ID not in (select B.BUILD_ID from BUILD B); delete from AGENT_ASSIGNMENT where EXECUTABLE_TYPE = 'PROJECT' and EXECUTABLE_ID not in (select P.PROJECT_ID from PROJECT P); delete from AGENT_ASSIGNMENT where EXECUTABLE_TYPE = 'ENVIRONMENT' and EXECUTABLE_ID not in (select E.ENVIRONMENT_ID from DEPLOYMENT_ENVIRONMENT E); delete from AGENT_ASSIGNMENT where EXECUTABLE_TYPE = 'DEPLOYMENT_PROJECT' and EXECUTABLE_ID not in (select P.DEPLOYMENT_PROJECT_ID from DEPLOYMENT_PROJECT P);