in asfyaml/feature/pelican.py [0:0]
def run(self):
"""
Pelican auto-build example:
pelican:
whoami: applicable branch (optional; 'asf-site' not allowed)
autobuild: folder/* (optional)
target: branch (optional)
theme: name (optional, default: 'theme')
notify: recipients (optional)
"""
# Don't build from asf-site, like...ever
ref = self.instance.branch
if ref == "asf-site":
print("Not auto-building from asf-site, ever...")
return
autobuild = self.yaml.get("autobuild")
if autobuild:
assert autobuild.endswith("/*"), "autobuild parameter must be $foo/*, e.g. site/* or feature/*"
do_autobuild = (
autobuild and fnmatch.fnmatch(ref, autobuild) and not ref.endswith("-staging")
) # don't autobuild the autobuilt
# If whoami specified, ignore this payload if branch does not match
whoami = self.yaml.get("whoami")
if whoami and whoami != ref and not do_autobuild:
return
# Get target branch, if any, default to same branch
target = self.yaml.get("target", ref)
if do_autobuild:
ref_bare = ref.replace(autobuild[:-1], "", 1) # site/foo -> foo
target = f"{autobuild[:-2]}/{ref_bare}-staging" # site/foo -> site/foo-staging
# Get optional theme
theme = self.yaml.get("theme", "theme")
# Get notification list - TODO: fix to reuse the old default git recipients
pnotify = self.yaml.get("notify", f"commits@{self.repository.hostname}.apache.org")
payload = {
"method": "force",
"jsonrpc": "2.0",
"id": 0,
"params": {
"reason": f"Triggered pelican auto-build via .asf.yaml by {self.committer.username}",
"builderid": "3",
"source": f"https://gitbox.apache.org/repos/asf/{self.repository.name!s}.git",
"sourcebranch": ref,
"outputbranch": target,
"project": self.repository.project,
"theme": theme,
"notify": pnotify,
},
}
print("Triggering pelican build...")
if not self.noop("pelican"):
# Contact buildbot 2
bbusr, bbpwd = open("/x1/gitbox/auth/bb2.txt").read().strip().split(":", 1)
s = requests.Session()
s.get("https://ci2.apache.org/auth/login", auth=(bbusr, bbpwd))
s.post("https://ci2.apache.org/api/v2/forceschedulers/pelican_websites", json=payload)
else:
print(payload)
print("Done!")