Git-Auto-Deploy
Git-Auto-Deploy copied to clipboard
How can I differentiate a push from a branch in bitbucket?
My project has two Master and Dev branches. I am trying to deploy both branches in different URLs, but I have a problem. I'm using bitbucket.
But I'm having a problem, I try to add filters to differentiate between both branches, but whenever I push the branch Dev Git-Auto-Deploy executes the deploys of both branches when they are detected as repo: push.
I've also tried adding the following filter:
"repositories": [
{
"url": "https://[email protected]/my-repo/repo.git",
"branch": "dev",
"remote": "origin",
"path": "my-path",
"deploy": "bash deploy.sh",
"header-filter": {
"X-Event-Key": "repo:push"
},
"payload-filter": [
{
"push.changes.old.type": "branch",
"push.changes.old.name": "dev"
}
]
},
{
"url": "https://[email protected]/my-repo/repo.git",
"branch": "dev",
"remote": "origin",
"path": "my-path",
"deploy": "bash deploy.sh",
"header-filter": {
"X-Event-Key": "repo:push"
},
"payload-filter": [
{
"push.changes.old.type": "branch",
"push.changes.old.name": "dev"
}
]
}
]
It shows me the following error:
Filter 'push.changes.old.type' does not match since the path is invalid
I've been guided by this issue to do that https://github.com/olipo186/Git-Auto-Deploy/issues/154
Body request:
Payloads are different for Server instance, see here https://confluence.atlassian.com/bitbucketserver058/event-payload-947167744.html
I am not sure how I can filter for changes here, since "changes" is of type array, and I need to access the first index here.
Payload:
{
"eventKey":"repo:refs_changed",
"date":"2017-09-19T09:45:32+1000",
"actor":{
"name":"admin",
"emailAddress":"[email protected]",
"id":1,
"displayName":"Administrator",
"active":true,
"slug":"admin",
"type":"NORMAL"
},
"repository":{
"slug":"repository",
"id":84,
"name":"repository",
"scmId":"git",
"state":"AVAILABLE",
"statusMessage":"Available",
"forkable":true,
"project":{
"key":"PROJ",
"id":84,
"name":"project",
"public":false,
"type":"NORMAL"
},
"public":false
},
"changes":[
{
"ref":{
"id":"refs/heads/master",
"displayId":"master",
"type":"BRANCH"
},
"refId":"refs/heads/master",
"fromHash":"ecddabb624f6f5ba43816f5926e580a5f680a932",
"toHash":"178864a7d521b6f5e720b386b2c2b0ef8563e0dc",
"type":"UPDATE"
}
]
}
for push event
Tried:
"payload-filter": [
{
"actor.name":"xxx",
"changes[0].ref.type": "branch"
}
]
Filter 'changes[0].ref.type' does not match since the path is invalid
Also tried
"changes.ref.type": "branch"
"changes.0.ref.type": "branch"
edit
OK, it seems only official bitbucket cloud server structure is supported according to https://github.com/olipo186/Git-Auto-Deploy/blob/ca9e5dc1d1732135a6389af090162afb56c1a926/gitautodeploy/parsers/bitbucket.py not the self hosted variant bitbucket server. :/
"repositories": [
{
"url": "ssh://[email protected]:7999/xxxx/xxxx-middleware.git",
"match-url": "xxxx-middleware",
"branch": "live_TEST",
"path": "~/xxxx",
"remote": "origin",
"deploy": "echo hi",
"header-filter": {
"X-Event-Key": "repo:refs_changed"
},
"payload-filter": [
{
"actor.name":"xxxx",
"changes.ref.type": "BRANCH",
"changes.ref.displayId":"live_TEST"
}
]
}
]
works fine with
https://github.com/pquerner/Git-Auto-Deploy/commit/90abb3a32eebb3853c1ec702e0a7093c7626d2d2
(This filter triggers when a push is received on branch live_TEST)