Fixed Jenkinsfile

This commit is contained in:
2026-05-19 17:34:10 +02:00
parent 367568860a
commit 2ef0084fe5
2 changed files with 36 additions and 55 deletions

View File

@@ -66,12 +66,12 @@ pipeline {
# ── playwright-stealth version check ─────────────── # ── playwright-stealth version check ───────────────
pip show playwright-stealth | grep -E "^(Name|Version)" pip show playwright-stealth | grep -E "^(Name|Version)"
python3 -c " python3 -c "
try: try:
from playwright_stealth import stealth_sync from playwright_stealth import stealth_sync
print('playwright_stealth OK (v1.x - stealth_sync)') print('playwright_stealth OK (v1.x - stealth_sync)')
except ImportError: except ImportError:
from playwright_stealth import Stealth from playwright_stealth import Stealth
print('playwright_stealth OK (v2.x - Stealth class)') print('playwright_stealth OK (v2.x - Stealth class)')
" "
# ── Sanity checks ────────────────────────────────── # ── Sanity checks ──────────────────────────────────

View File

@@ -12,12 +12,6 @@ pipeline {
cron('H/30 * * * *') cron('H/30 * * * *')
} }
environment {
VENV_DIR = 'venv'
PIP_CACHE_DIR = "${WORKSPACE}/.pip-cache"
PYTHONUNBUFFERED = '1'
}
stages { stages {
// ───────────────────────────────────────────── // ─────────────────────────────────────────────
@@ -35,27 +29,20 @@ pipeline {
stage('Setup Python & Install Dependencies') { stage('Setup Python & Install Dependencies') {
steps { steps {
sh ''' sh '''
set -euxo pipefail set -e
# ── Playwright system dependencies (required in CI) ─
# Installs libglib, libnss, libatk, libdrm, etc.
# Safe to run even if already installed — exits 0.
"${VENV_DIR}/bin/python" -m playwright install-deps chromium || \
sudo playwright install-deps chromium || \
echo "⚠️ playwright install-deps skipped (no sudo) — continuing"
# ── Create venv ──────────────────────────────────── # ── Create venv ────────────────────────────────────
python3 -m venv "${VENV_DIR}" python3 -m venv venv
# ── Upgrade pip toolchain ────────────────────────── # ── Upgrade pip toolchain ──────────────────────────
"${VENV_DIR}/bin/python" -m pip install --upgrade pip wheel setuptools . venv/bin/activate
pip install --upgrade pip wheel setuptools
# ── Install all required packages ────────────────── # ── Core dependencies ──────────────────────────────
"${VENV_DIR}/bin/pip" install \ pip install -U \
--cache-dir "${PIP_CACHE_DIR}" \
-U \
atproto \ atproto \
playwright \ playwright \
playwright-stealth \
httpx \ httpx \
arrow \ arrow \
python-dotenv \ python-dotenv \
@@ -67,46 +54,40 @@ pipeline {
# ── yt-dlp: always upgrade to latest ────────────── # ── yt-dlp: always upgrade to latest ──────────────
# TikTok extractor breaks frequently — latest is required # TikTok extractor breaks frequently — latest is required
"${VENV_DIR}/bin/pip" install \ pip install --upgrade yt-dlp
--cache-dir "${PIP_CACHE_DIR}" \ pip show yt-dlp | grep -E "^(Name|Version)"
--upgrade \
"yt-dlp"
# Print installed yt-dlp version for traceability # ── curl_cffi: TikTok impersonation (REQUIRED) ─────
"${VENV_DIR}/bin/pip" show yt-dlp | grep -E "^(Name|Version)" # Without this yt-dlp cannot bypass TikTok bot detection
pip install --upgrade curl-cffi
pip show curl-cffi | grep -E "^(Name|Version)"
python3 -c "import curl_cffi; print('curl_cffi OK')"
# ── playwright-stealth ───────────────────────────── # ── playwright-stealth version check ───────────────
"${VENV_DIR}/bin/pip" install \ pip show playwright-stealth | grep -E "^(Name|Version)"
--cache-dir "${PIP_CACHE_DIR}" \ python3 -c "
-U playwright-stealth try:
from playwright_stealth import stealth_sync
# Print which version was installed for traceability print('playwright_stealth OK (v1.x - stealth_sync)')
"${VENV_DIR}/bin/pip" show playwright-stealth | grep -E "^(Name|Version)" except ImportError:
from playwright_stealth import Stealth
# Verify the stealth import works (handles both v1 and v2) print('playwright_stealth OK (v2.x - Stealth class)')
"${VENV_DIR}/bin/python" -c "
try:
from playwright_stealth import stealth_sync
print('playwright_stealth OK (v1.x - stealth_sync)')
except ImportError:
from playwright_stealth import Stealth
print('playwright_stealth OK (v2.x - Stealth class)')
" "
# ── Sanity checks ────────────────────────────────── # ── Sanity checks ──────────────────────────────────
"${VENV_DIR}/bin/python" -c "import atproto; print('atproto OK')" python3 -c "import atproto; print('atproto OK')"
"${VENV_DIR}/bin/python" -c "import playwright; print('playwright OK')" python3 -c "import playwright; print('playwright OK')"
"${VENV_DIR}/bin/python" -c "import yt_dlp; print('yt_dlp OK')" python3 -c "import yt_dlp; print('yt_dlp OK')"
"${VENV_DIR}/bin/python" -c "import httpx; print('httpx OK')" python3 -c "import httpx; print('httpx OK')"
"${VENV_DIR}/bin/python" -c "import arrow; print('arrow OK')" python3 -c "import arrow; print('arrow OK')"
"${VENV_DIR}/bin/python" -c "import moviepy; print('moviepy OK')" python3 -c "import moviepy; print('moviepy OK')"
# ── System tools ─────────────────────────────────── # ── System tools ───────────────────────────────────
ffmpeg -version | head -1 ffmpeg -version | head -1
ffprobe -version | head -1 ffprobe -version | head -1
# ── Playwright browser binaries ──────────────────── # ── Playwright browser binaries ────────────────────
"${VENV_DIR}/bin/python" -m playwright install chromium playwright install chromium
''' '''
} }
} }