JeanRev / TeamcityDockerCloudPlugin

Docker Cloud Plugin for the TeamCity build server
Apache License 2.0
32 stars 10 forks source link

Cloud Profile Agent Images Container (Windows) Errors #39

Open bourgeoisrebel opened 5 years ago

bourgeoisrebel commented 5 years ago

When you create an agent image under a cloud profile using the containers (preview) windows option, the deployment fails with the error below. It appears, looking in the template by drilling in to the deployment in the portal, that the windows deployment has environment variables that aren't used in the Linux one (which works beautifully). These variables are given invalid names, using '.', where only alphabetic and underscores are allowed.

{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.","details":[{"code":"BadRequest","message":"{\r\n \"error\": {\r\n \"code\": \"InvalidContainerEnvironmentVariable\",\r\n \"message\": \"The environment variable name in container 'teamcity-course-win-agent1' of container group 'teamcity-course-win-agent1' is invalid. A valid environment variable name must start with alphabetic character or '', followed by a string of alphanumeric characters or '' (e.g. 'my_name', or 'MY_NAME', or 'MyName').\"\r\n }\r\n}"}]}

Environment Variables section of failing windows one:

                       "environmentVariables": [
                            {
                                "name": "SERVER_URL",
                                "value": "[parameters('teamcityUrl')]"
                            },
                            {
                                "name": "AGENT_NAME",
                                "value": "teamcity-course-win-agent1"
                            },
                            {
                                "name": "TC_AZURE_system.cloud.profile_id",
                                "value": "arm-7"
                            },
                            {
                                "name": "TC_AZURE_teamcity.cloud.instance.hash",
                                "value": "FfWzTvTVHOMKiqlpXpc2CN66L5HGA9zo"
                            },
                            {
                                "name": "TC_AZURE_azure.instance.name",
                                "value": "teamcity-course-win-agent1"
                            }
                        ],

Working Linux one:

                        "environmentVariables": [
                            {
                                "name": "SERVER_URL",
                                "value": "[parameters('teamcityUrl')]"
                            },
                            {
                                "name": "AGENT_NAME",
                                "value": "teamcity-course-agent1"
                            }
                        ],
JeanRev commented 5 years ago

Hi @bourgeoisrebel

Sorry for the late reply! The environment variables with dots in their names, and prefixed with TC_AZURE, are actually set by the Teamcity Azure cloud plugin. And I really can't say why they are showing up in your deployment :-)

The Docker plugin uses "TC_DK_CLD" for all its environment variable names, and they never contains dots. You could maybe review the Docker image used in your cloud profile to see if, for some reason, these environment variables are defined there.