Cookies 6

This commit is contained in:
Guillem Hernandez Sola
2026-05-19 11:16:20 +02:00
parent ab32d5b5e4
commit 998c18af8d

View File

@@ -13,8 +13,8 @@ pipeline {
} }
environment { environment {
VENV_DIR = 'venv' VENV_DIR = 'venv'
PIP_CACHE_DIR = "${WORKSPACE}/.pip-cache" PIP_CACHE_DIR = "${WORKSPACE}/.pip-cache"
PYTHONUNBUFFERED = '1' PYTHONUNBUFFERED = '1'
} }
@@ -49,7 +49,6 @@ pipeline {
-U \ -U \
atproto \ atproto \
playwright \ playwright \
playwright-stealth \
yt-dlp \ yt-dlp \
httpx \ httpx \
arrow \ arrow \
@@ -60,12 +59,29 @@ pipeline {
Pillow \ Pillow \
grapheme grapheme
# ── Install playwright-stealth and detect version ──
"${VENV_DIR}/bin/pip" install --cache-dir "${PIP_CACHE_DIR}" -U playwright-stealth
# Print which version was installed for traceability
"${VENV_DIR}/bin/pip" show playwright-stealth | grep -E "^(Name|Version)"
# Verify the stealth import works (handles both v1 and v2)
"${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 moviepy; print('moviepy OK')" "${VENV_DIR}/bin/python" -c "import atproto; print('atproto OK')"
"${VENV_DIR}/bin/python" -c "import atproto; print('atproto OK')" "${VENV_DIR}/bin/python" -c "import playwright; print('playwright OK')"
"${VENV_DIR}/bin/python" -c "import playwright; print('playwright OK')" "${VENV_DIR}/bin/python" -c "import yt_dlp; print('yt_dlp OK')"
"${VENV_DIR}/bin/python" -c "import playwright_stealth; print('playwright_stealth OK')" "${VENV_DIR}/bin/python" -c "import httpx; print('httpx OK')"
"${VENV_DIR}/bin/python" -c "import yt_dlp; print('yt_dlp OK')" "${VENV_DIR}/bin/python" -c "import arrow; print('arrow OK')"
"${VENV_DIR}/bin/python" -c "import moviepy; print('moviepy OK')"
# ── System tools ─────────────────────────────────── # ── System tools ───────────────────────────────────
ffmpeg -version | head -1 ffmpeg -version | head -1
@@ -95,9 +111,6 @@ pipeline {
credentialsId: 'BSKY_JIJANTESFC_APP_PASSWORD', credentialsId: 'BSKY_JIJANTESFC_APP_PASSWORD',
variable: 'BSKY_JIJANTESFC_APP_PASSWORD' variable: 'BSKY_JIJANTESFC_APP_PASSWORD'
), ),
// Secret File: upload tiktok_cookies.json once via
// Jenkins → Manage Credentials → Secret file
// ID: TIKTOK_COOKIES_JSON
file( file(
credentialsId: 'TIKTOK_COOKIES_JSON', credentialsId: 'TIKTOK_COOKIES_JSON',
variable: 'TIKTOK_COOKIES_FILE' variable: 'TIKTOK_COOKIES_FILE'
@@ -110,12 +123,12 @@ pipeline {
cp "$TIKTOK_COOKIES_FILE" tiktok_cookies.json cp "$TIKTOK_COOKIES_FILE" tiktok_cookies.json
"${VENV_DIR}/bin/python" tiktok2bsky.py \ "${VENV_DIR}/bin/python" tiktok2bsky.py \
--tiktok-handle "$TIKTOK_JIJANTESFC_HANDLE" \ --tiktok-handle "$TIKTOK_JIJANTESFC_HANDLE" \
--bsky-handle "$BSKY_JIJANTESFC_HANDLE" \ --bsky-handle "$BSKY_JIJANTESFC_HANDLE" \
--bsky-password "$BSKY_JIJANTESFC_APP_PASSWORD" \ --bsky-app-password "$BSKY_JIJANTESFC_APP_PASSWORD" \
--bsky-base-url https://eurosky.social \ --bsky-base-url https://eurosky.social \
--bsky-langs es \ --bsky-langs es \
--cookies-path tiktok_cookies.json --cookies-path tiktok_cookies.json
''' '''
} }
} }
@@ -128,14 +141,13 @@ pipeline {
post { post {
always { always {
// Archive logs, state, and any CAPTCHA screenshots // Archive logs, state, and any CAPTCHA/debug screenshots
archiveArtifacts( archiveArtifacts(
artifacts: '*.log, *.json, screenshot_*.png', artifacts: '*.log, *.json, screenshot_*.png',
allowEmptyArchive: true allowEmptyArchive: true
) )
// Clean up the injected cookies file from workspace // Remove injected cookies file — never leave on disk between runs
// so it is never left on disk between runs
sh 'rm -f tiktok_cookies.json || true' sh 'rm -f tiktok_cookies.json || true'
} }