Make task publication opt in
This commit is contained in:
parent
32173a8fb8
commit
e9f1e0e97e
|
|
@ -9,7 +9,7 @@ pipeline {
|
|||
}
|
||||
|
||||
environment {
|
||||
ASSET_SOURCE_DIR = 'tasks'
|
||||
ASSET_SOURCE_DIR = 'shared-tasks'
|
||||
ASSET_PUBLISH_ROOT = '/mnt/assets/agent-tasks'
|
||||
}
|
||||
|
||||
|
|
@ -21,13 +21,18 @@ pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
stage('Validate publishable tasks') {
|
||||
stage('Discover publishable tasks') {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
|
||||
test -d "${ASSET_SOURCE_DIR}" || {
|
||||
echo "ERROR: ${ASSET_SOURCE_DIR} is not a directory." >&2
|
||||
if [ ! -e "${ASSET_SOURCE_DIR}" ]; then
|
||||
echo "No ${ASSET_SOURCE_DIR}/ directory; nothing is marked for publication."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
test -d "${ASSET_SOURCE_DIR}" && test ! -L "${ASSET_SOURCE_DIR}" || {
|
||||
echo "ERROR: ${ASSET_SOURCE_DIR} must be a real directory." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
|
@ -47,11 +52,6 @@ pipeline {
|
|||
task_count=$((task_count + 1))
|
||||
done
|
||||
|
||||
test "${task_count}" -gt 0 || {
|
||||
echo "ERROR: no publishable *.task.md files were found." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
unexpected=$(find "${ASSET_SOURCE_DIR}" -mindepth 1 \
|
||||
\( ! -type f -o ! -name '*.task.md' \) -print -quit)
|
||||
test -z "${unexpected}" || {
|
||||
|
|
@ -59,7 +59,11 @@ pipeline {
|
|||
exit 1
|
||||
}
|
||||
|
||||
echo "Validated ${task_count} task files for publication."
|
||||
if [ "${task_count}" -eq 0 ]; then
|
||||
echo "No shared task files are marked for publication."
|
||||
else
|
||||
echo "Validated ${task_count} shared task files for publication."
|
||||
fi
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
|
@ -72,6 +76,17 @@ pipeline {
|
|||
sh '''
|
||||
set -eu
|
||||
|
||||
if [ ! -d "${ASSET_SOURCE_DIR}" ]; then
|
||||
echo "Nothing is marked for publication."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set -- "${ASSET_SOURCE_DIR}"/*.task.md
|
||||
if [ ! -e "$1" ]; then
|
||||
echo "Nothing is marked for publication."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case "${ASSET_PUBLISH_ROOT}" in
|
||||
/*) ;;
|
||||
*)
|
||||
|
|
@ -83,7 +98,7 @@ pipeline {
|
|||
mkdir -p "${ASSET_PUBLISH_ROOT}"
|
||||
chmod 0755 "${ASSET_PUBLISH_ROOT}"
|
||||
|
||||
for source in "${ASSET_SOURCE_DIR}"/*.task.md; do
|
||||
for source in "$@"; do
|
||||
name=${source##*/}
|
||||
destination="${ASSET_PUBLISH_ROOT}/${name}"
|
||||
temporary="${destination}.tmp-${BUILD_NUMBER}-$$"
|
||||
|
|
|
|||
20
README.md
20
README.md
|
|
@ -18,9 +18,15 @@ adapt the brief to its existing CI, tools, metadata, and commit conventions.
|
|||
|
||||
## Publishing
|
||||
|
||||
The `tasks/` directory is also the publication contract. Jenkins validates that
|
||||
it contains only nonempty, regular `*.task.md` files. On `main`, it copies each
|
||||
file atomically to:
|
||||
Tasks are private to the repository by default:
|
||||
|
||||
- `tasks/` contains ordinary task briefs and is never published.
|
||||
- `shared-tasks/` is an explicit opt-in publication directory.
|
||||
|
||||
The current briefs are in `tasks/`, so Jenkins has nothing to publish. To share
|
||||
a task publicly, move it to `shared-tasks/`. Jenkins validates that this
|
||||
optional directory contains only nonempty, regular `*.task.md` files. On
|
||||
`main`, it copies each shared file atomically to:
|
||||
|
||||
```text
|
||||
/mnt/assets/agent-tasks/<task-name>.task.md
|
||||
|
|
@ -32,6 +38,8 @@ The files are then available at:
|
|||
https://assets.dandaedre.com/agent-tasks/<task-name>.task.md
|
||||
```
|
||||
|
||||
Other branches are validated but are not published. Publication intentionally
|
||||
does not delete files from the shared asset mount, so removing or renaming a
|
||||
task requires a separate, explicitly approved cleanup of its old public file.
|
||||
If `shared-tasks/` is absent or contains no task files, the pipeline succeeds
|
||||
without touching the asset mount. Other branches validate shared files but do
|
||||
not publish them. Publication intentionally does not delete files from the
|
||||
shared asset mount, so unsharing, removing, or renaming a task requires a
|
||||
separate, explicitly approved cleanup of its old public file.
|
||||
|
|
|
|||
Loading…
Reference in New Issue