create_pipeline_variable
Add secure or plain-text configuration variables to Bitbucket pipelines for managing secrets and environment settings.
Instructions
Create a pipeline variable.
Args:
repo_slug: Repository slug
key: Variable name (e.g., "PYPI_TOKEN", "AWS_SECRET_KEY")
value: Variable value
secured: Whether to encrypt the value (default: False).
Secured variables cannot be read back from the API.
Returns:
Created variable info with UUID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repo_slug | Yes | ||
| key | Yes | ||
| value | Yes | ||
| secured | No |
Implementation Reference
- src/server.py:530-558 (handler)MCP tool handler for create_pipeline_variable. This is the main execution function decorated with @mcp.tool(), which handles the tool call, gets the Bitbucket client, calls the underlying client method, and returns formatted response.@mcp.tool() @handle_bitbucket_error @formatted def create_pipeline_variable( repo_slug: str, key: str, value: str, secured: bool = False, ) -> dict: """Create a pipeline variable. Args: repo_slug: Repository slug key: Variable name (e.g., "PYPI_TOKEN", "AWS_SECRET_KEY") value: Variable value secured: Whether to encrypt the value (default: False). Secured variables cannot be read back from the API. Returns: Created variable info with UUID """ client = get_client() result = client.create_pipeline_variable(repo_slug, key, value, secured) return { "uuid": result.get("uuid"), "key": result.get("key"), "secured": result.get("secured"), }
- src/bitbucket_client.py:683-707 (helper)Helper method in BitbucketClient that performs the actual Bitbucket API POST request to create the pipeline variable.def create_pipeline_variable( self, repo_slug: str, key: str, value: str, secured: bool = False, ) -> dict[str, Any]: """Create a pipeline variable. Args: repo_slug: Repository slug key: Variable name (e.g., "PYPI_TOKEN") value: Variable value secured: Whether to encrypt the value (default: False) Returns: Created variable info """ payload = {"key": key, "value": value, "secured": secured} result = self._request( "POST", self._repo_path(repo_slug, "pipelines_config", "variables") + "/", json=payload, ) return self._require_result(result, "create pipeline variable")
- src/server.py:530-530 (registration)The @mcp.tool() decorator registers the create_pipeline_variable function as an MCP tool.@mcp.tool()