2.5 KiB
2.5 KiB
🎯 STEP-BY-STEP: Fix Node 7 Data (Follow Exactly)
The Problem:
Node 2 has: repo_full_name = "gitadmin/test-repo"
Node 7 wants: repo_full_name
BUT: Node 3 loses the data! ❌
The Solution:
Store data in a "shared box" (staticData) that all nodes can access
STEP 1: Fix Node 2
- Open Node 2 "Extract Repo Info"
- Find this line in the code:
return {
repo_name: repoName,
repo_full_name: repoFullName,
...
};
- ADD THESE LINES BEFORE the return statement:
// NEW: Store data in shared storage
$workflow.staticData = $workflow.staticData || {};
$workflow.staticData.repo_info = {
repo_name: repoName,
repo_full_name: repoFullName,
repo_clone_url: repoCloneUrl,
branch: branch,
commit_sha: commitSha,
commit_message: commitMessage,
pusher: pusher
};
- Keep the existing return statement too (don't delete it)
STEP 2: Fix Node 7
- Open Node 7 "Format Build Response"
- REPLACE ALL CODE with:
// NEW: Read from shared storage
const repoInfo = $workflow.staticData.repo_info || {};
const buildStatus = $json;
const result = {
status: buildStatus.status || 'SUCCESS',
repo: repoInfo.repo_full_name || 'unknown',
branch: repoInfo.branch || 'main',
commit: repoInfo.commit_sha ? repoInfo.commit_sha.substring(0, 8) : 'N/A',
message: buildStatus.message || 'Build completed',
timestamp: new Date().toISOString(),
retry_count: ($workflow.staticData && $workflow.staticData.retry_count) || 0
};
if (result.status === 'SUCCESS') {
result.emoji = '✅';
} else if (result.status === 'FAILED') {
result.emoji = '❌';
} else {
result.emoji = '⚠️';
}
return result;
STEP 3: Save and Test
- Click Save (top-right)
- Test with curl:
curl -X POST https://n8n.oky.sh/webhook/openhands-enhanced \
-H "Content-Type: application/json" \
-d '{"repository": {"full_name": "gitadmin/test-repo"}, "commits": [{"message": "Test"}]}'
- Check n8n Executions → Node 7 output
Expected Result:
{
"status": "SUCCESS",
"repo": "gitadmin/test-repo", ← NOW SHOWS ACTUAL NAME!
"branch": "main",
"commit": "abc12345", ← NOW SHOWS ACTUAL COMMIT!
"message": "Build completed successfully",
"emoji": "✅"
}
Visual Summary:
Node 2: Creates data → Saves to "shared box" ($workflow.staticData)
↓
Node 3: SSH runs → (data stays in shared box)
↓
Node 7: Reads from "shared box" → Has all data! ✅
The "shared box" (staticData) persists across all nodes!