Portainer icon

Portainer

Interact with Portainer via API

Actions190

Stacks → Stack Git Redeploy

AI-generated

Overview

The "Stack Git Redeploy" operation for the "Stacks" resource allows users to trigger a redeployment of a stack by pulling updated Git configurations. This is useful in scenarios where infrastructure or application stacks managed via Portainer need to be updated automatically based on changes in their Git repositories. For example, after pushing new code or configuration changes to a Git repository, this node can pull those changes and redeploy the stack accordingly, ensuring that the running environment reflects the latest updates.

Properties

Name Meaning
Id The unique identifier of the stack to redeploy.
Body A JSON string containing Git configuration details for pulling and redeploying the stack. For Kubernetes stacks, the StackName field may be included; if set as an empty string, it will clear the name.
Additional Fields Optional extra parameters:
- Endpoint Id: For stacks created before version 1.18.0 that might lack an associated environment (endpoint) ID, this number sets the environment ID used by the stack.

Output

The node outputs JSON data representing the response from the Portainer API after attempting the Git redeploy operation on the specified stack. This typically includes status information about the redeployment process, success confirmation, or error details if the operation failed.

No binary data output is expected from this node.

Dependencies

  • Requires an active connection to a Portainer instance via its API.
  • Needs an API authentication token or key configured in n8n credentials to authorize requests.
  • The base URL of the Portainer API must be provided in the credentials.
  • The node uses HTTP requests with JSON payloads to interact with the Portainer API.

Troubleshooting

  • Common Issues:

    • Invalid or missing stack ID: Ensure the stack identifier is correct and exists in Portainer.
    • Incorrect or malformed Git configuration JSON in the Body property: Validate the JSON format and required fields.
    • Missing or invalid API credentials: Verify that the API key/token and base URL are correctly configured.
    • Endpoint ID mismatch for older stacks: If redeploy fails due to environment issues, try specifying the Endpoint Id in Additional Fields.
  • Error Messages:

    • Authentication errors usually indicate invalid or expired API credentials.
    • 404 Not Found errors suggest the stack ID does not exist or is inaccessible.
    • 400 Bad Request errors often mean the Git config body is improperly formatted or missing required fields.

Resolving these generally involves verifying input parameters, checking API credentials, and confirming the stack's existence and state in Portainer.

Links and References

Discussion