Hi Team,
Does anyone have an idea of how to configure webhooks with Azure Devops?
I running AWX 21.4 installed via the Operator 0.26 on K3s 1.21, works great.
But our repositories are on Azure Devops and AWX seem to only support Github and Gitlab for webhooks.
Any pointers would be much appreciated.
Kind regards,
Hi,
Azure Devops is not currently supported, as you mention. There is an issue to support it here https://github.com/ansible/awx/issues/8050 (please thumbs it up), but this feature is not currently in the works.
That said, AWX would certainly welcome a PR for this feature work, if someone can get one up
AWX Team
Thanks you for the confirmation, hope this gets implemented at some point.
Especially since I am noticing an increasing number of clients using Azure DevOps (Microsoft ecosystem)
Regards,
I have a bridge from ADO git webhook to AWX API, but it's part of something else that was already bridging events between AWX API and our internal CMDB. It's quite simple though (this is a view within a small Flask web application). It receives webhook notifications from ADO, iterates through a list of awx servers and all the projects on each to see if this git update is relevant to them. If it is, it tells awx to update that project. Maybe useful for someone to make a standalone/integrated thing from? I don't have the time to do it, personally.
Howard
from towerlib import Tower
from giturlparse import parse
@basicapp.route('/git-status-update', methods=['POST'])
def git_update():
"""Incoming notice from ADO that a git repo has been updated."""
if request.is_json:
current_app.logger.info(request.json)
message = request\.json
try:
repo\_url = message\['resource'\]\['repository'\]\['remoteUrl'\]
hook\_repo = parse\(repo\_url\)
branch = message\['resource'\]\['repository'\]\['defaultBranch'\]
print\(hook\_repo\.host, hook\_repo\.name, hook\_repo\.owner\)
current\_app\.logger\.info\("Got an update for the %s branch of %s", branch, repo\_url\)
except Exception as e:
\# if anything in here fails, it doesn't matter too much
current\_app\.logger\.error\(e\)
return "FAILED TO PARSE UPDATE", 500
for awx in known\_awx:
try:
tower = Tower\(awx\.hostname, None, None, secure=awx\.use\_tls, token=awx\.token\)
current\_app\.logger\.info\("Finding projects in %s", awx\.hostname\)
for p in tower\.projects:
current\_app\.logger\.debug\(f"\{p\.id\} \{p\.name\} \{p\.scm\_url\}"\)
project\_repo = parse\(p\.scm\_url\)
if hook\_repo\.name == project\_repo\.name:
current\_app\.logger\.info\(f"THIS IS THE ONE WE WANT TO SYNC \- ID \{p\.id\}"\)
\# POST to https://awx-server/api/v2/projects/24/update/
url = f"\{tower\.api\}/projects/\{p\.id\}/update/"
current\_app\.logger\.info\("POST to %s", url\)
tower\.session\.post\(url, json=\{"can\_update": True\}\)
except Exception as e:
\# if anything in here fails, it doesn't matter too much
current\_app\.logger\.error\(e\)
else:
current\_app\.logger\.error\("No JSON"\)
current\_app\.logger\.debug\(request\.data\)
return "OK"