diff --git a/jenkins/3CatCampusTikTok b/jenkins/3CatCampusTikTok index 12dea73..52b336c 100644 --- a/jenkins/3CatCampusTikTok +++ b/jenkins/3CatCampusTikTok @@ -14,32 +14,25 @@ pipeline { stages { - // ───────────────────────────────────────────── - // 1. Checkout - // ───────────────────────────────────────────── stage('Checkout Code') { steps { checkout scm } } - // ───────────────────────────────────────────── - // 2. Python env + dependencies - // ───────────────────────────────────────────── stage('Setup Python & Install Dependencies') { steps { sh ''' set -e + cd "$WORKSPACE" - # ── Create venv ──────────────────────────────────── + # Crea el venv python3 -m venv venv - # ── Upgrade pip toolchain ────────────────────────── - . venv/bin/activate - pip install --upgrade pip wheel setuptools + # Usa sempre python3 -m pip, mai el binari pip directament + "$WORKSPACE/venv/bin/python3" -m pip install --upgrade pip wheel setuptools - # ── Core dependencies ────────────────────────────── - pip install -U \ + "$WORKSPACE/venv/bin/python3" -m pip install -U \ atproto \ playwright \ playwright-stealth \ @@ -50,44 +43,19 @@ pipeline { beautifulsoup4 \ charset-normalizer \ Pillow \ - grapheme + grapheme \ + yt-dlp \ + curl-cffi - # ── yt-dlp: always upgrade to latest ────────────── - # TikTok extractor breaks frequently — latest is required - pip install --upgrade yt-dlp - pip show yt-dlp | grep -E "^(Name|Version)" + # Sanity checks + "$WORKSPACE/venv/bin/python3" -c "import atproto; print('atproto OK')" + "$WORKSPACE/venv/bin/python3" -c "import playwright; print('playwright OK')" + "$WORKSPACE/venv/bin/python3" -c "import yt_dlp; print('yt_dlp OK')" + "$WORKSPACE/venv/bin/python3" -c "import curl_cffi; print('curl_cffi OK')" - # ── curl_cffi: TikTok impersonation (REQUIRED) ───── - # 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 version check ─────────────── - pip show playwright-stealth | grep -E "^(Name|Version)" - python3 -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 ────────────────────────────────── - python3 -c "import atproto; print('atproto OK')" - python3 -c "import playwright; print('playwright OK')" - python3 -c "import yt_dlp; print('yt_dlp OK')" - python3 -c "import httpx; print('httpx OK')" - python3 -c "import arrow; print('arrow OK')" - python3 -c "import moviepy; print('moviepy OK')" - - # ── System tools ─────────────────────────────────── - ffmpeg -version | head -1 - ffprobe -version | head -1 - - # ── Playwright browser binaries ──────────────────── - playwright install chromium + # Playwright browser binaries + PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \ + "$WORKSPACE/venv/bin/python3" -m playwright install chromium ''' } } diff --git a/jenkins/3CatCulturaTikTok b/jenkins/3CatCulturaTikTok index 3148f5b..80272e6 100644 --- a/jenkins/3CatCulturaTikTok +++ b/jenkins/3CatCulturaTikTok @@ -14,32 +14,25 @@ pipeline { stages { - // ───────────────────────────────────────────── - // 1. Checkout - // ───────────────────────────────────────────── stage('Checkout Code') { steps { checkout scm } } - // ───────────────────────────────────────────── - // 2. Python env + dependencies - // ───────────────────────────────────────────── stage('Setup Python & Install Dependencies') { steps { sh ''' set -e + cd "$WORKSPACE" - # ── Create venv ──────────────────────────────────── + # Crea el venv python3 -m venv venv - # ── Upgrade pip toolchain ────────────────────────── - . venv/bin/activate - pip install --upgrade pip wheel setuptools + # Usa sempre python3 -m pip, mai el binari pip directament + "$WORKSPACE/venv/bin/python3" -m pip install --upgrade pip wheel setuptools - # ── Core dependencies ────────────────────────────── - pip install -U \ + "$WORKSPACE/venv/bin/python3" -m pip install -U \ atproto \ playwright \ playwright-stealth \ @@ -50,91 +43,23 @@ pipeline { beautifulsoup4 \ charset-normalizer \ Pillow \ - grapheme + grapheme \ + yt-dlp \ + curl-cffi - # ── yt-dlp: always upgrade to latest ────────────── - # TikTok extractor breaks frequently — latest is required - pip install --upgrade yt-dlp - pip show yt-dlp | grep -E "^(Name|Version)" + # Sanity checks + "$WORKSPACE/venv/bin/python3" -c "import atproto; print('atproto OK')" + "$WORKSPACE/venv/bin/python3" -c "import playwright; print('playwright OK')" + "$WORKSPACE/venv/bin/python3" -c "import yt_dlp; print('yt_dlp OK')" + "$WORKSPACE/venv/bin/python3" -c "import curl_cffi; print('curl_cffi OK')" - # ── curl_cffi: TikTok impersonation (REQUIRED) ───── - # 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 version check ─────────────── - pip show playwright-stealth | grep -E "^(Name|Version)" - python3 -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 ────────────────────────────────── - python3 -c "import atproto; print('atproto OK')" - python3 -c "import playwright; print('playwright OK')" - python3 -c "import yt_dlp; print('yt_dlp OK')" - python3 -c "import httpx; print('httpx OK')" - python3 -c "import arrow; print('arrow OK')" - python3 -c "import moviepy; print('moviepy OK')" - - # ── System tools ─────────────────────────────────── - ffmpeg -version | head -1 - ffprobe -version | head -1 - - # ── Playwright browser binaries ──────────────────── - playwright install chromium + # Playwright browser binaries + PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \ + "$WORKSPACE/venv/bin/python3" -m playwright install chromium ''' } } - // ───────────────────────────────────────────── - // 3. Run the bot - // ───────────────────────────────────────────── - stage('Run Script') { - steps { - withCredentials([ - string( - credentialsId: 'TIKTOK_3CATCULTURA_HANDLE', - variable: 'TIKTOK_3CATCULTURA_HANDLE' - ), - string( - credentialsId: 'BSKY_3CAT_HANDLE', - variable: 'BSKY_3CAT_HANDLE' - ), - string( - credentialsId: 'BSKY_3CAT_APP_PASSWORD', - variable: 'BSKY_3CAT_APP_PASSWORD' - ), - file( - credentialsId: 'TIKTOK_COOKIES_JSON', - variable: 'TIKTOK_COOKIES_FILE' - ) - ]) { - sh ''' - set -e - - # Inject the secret cookies file into the workspace - cp "$TIKTOK_COOKIES_FILE" tiktok_cookies.json - - . venv/bin/activate - python3 tiktok2bsky.py \ - --tiktok-handle "$TIKTOK_3CATCULTURA_HANDLE" \ - --bsky-handle "$BSKY_3CAT_HANDLE" \ - --bsky-app-password "$BSKY_3CAT_APP_PASSWORD" \ - --bsky-base-url https://eurosky.social \ - --bsky-langs ca \ - --cookies-path tiktok_cookies.json - ''' - } - } - } - } - // ───────────────────────────────────────────── // Post actions // ───────────────────────────────────────────── diff --git a/jenkins/3CatPoloniaTikTok b/jenkins/3CatPoloniaTikTok index 117dc32..a860917 100644 --- a/jenkins/3CatPoloniaTikTok +++ b/jenkins/3CatPoloniaTikTok @@ -14,32 +14,25 @@ pipeline { stages { - // ───────────────────────────────────────────── - // 1. Checkout - // ───────────────────────────────────────────── stage('Checkout Code') { steps { checkout scm } } - // ───────────────────────────────────────────── - // 2. Python env + dependencies - // ───────────────────────────────────────────── stage('Setup Python & Install Dependencies') { steps { sh ''' set -e + cd "$WORKSPACE" - # ── Create venv ──────────────────────────────────── + # Crea el venv python3 -m venv venv - # ── Upgrade pip toolchain ────────────────────────── - . venv/bin/activate - pip install --upgrade pip wheel setuptools + # Usa sempre python3 -m pip, mai el binari pip directament + "$WORKSPACE/venv/bin/python3" -m pip install --upgrade pip wheel setuptools - # ── Core dependencies ────────────────────────────── - pip install -U \ + "$WORKSPACE/venv/bin/python3" -m pip install -U \ atproto \ playwright \ playwright-stealth \ @@ -50,44 +43,19 @@ pipeline { beautifulsoup4 \ charset-normalizer \ Pillow \ - grapheme + grapheme \ + yt-dlp \ + curl-cffi - # ── yt-dlp: always upgrade to latest ────────────── - # TikTok extractor breaks frequently — latest is required - pip install --upgrade yt-dlp - pip show yt-dlp | grep -E "^(Name|Version)" + # Sanity checks + "$WORKSPACE/venv/bin/python3" -c "import atproto; print('atproto OK')" + "$WORKSPACE/venv/bin/python3" -c "import playwright; print('playwright OK')" + "$WORKSPACE/venv/bin/python3" -c "import yt_dlp; print('yt_dlp OK')" + "$WORKSPACE/venv/bin/python3" -c "import curl_cffi; print('curl_cffi OK')" - # ── curl_cffi: TikTok impersonation (REQUIRED) ───── - # 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 version check ─────────────── - pip show playwright-stealth | grep -E "^(Name|Version)" - python3 -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 ────────────────────────────────── - python3 -c "import atproto; print('atproto OK')" - python3 -c "import playwright; print('playwright OK')" - python3 -c "import yt_dlp; print('yt_dlp OK')" - python3 -c "import httpx; print('httpx OK')" - python3 -c "import arrow; print('arrow OK')" - python3 -c "import moviepy; print('moviepy OK')" - - # ── System tools ─────────────────────────────────── - ffmpeg -version | head -1 - ffprobe -version | head -1 - - # ── Playwright browser binaries ──────────────────── - playwright install chromium + # Playwright browser binaries + PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \ + "$WORKSPACE/venv/bin/python3" -m playwright install chromium ''' } } diff --git a/jenkins/3CatTikTok b/jenkins/3CatTikTok index 7be74f7..324be54 100644 --- a/jenkins/3CatTikTok +++ b/jenkins/3CatTikTok @@ -14,32 +14,25 @@ pipeline { stages { - // ───────────────────────────────────────────── - // 1. Checkout - // ───────────────────────────────────────────── stage('Checkout Code') { steps { checkout scm } } - // ───────────────────────────────────────────── - // 2. Python env + dependencies - // ───────────────────────────────────────────── stage('Setup Python & Install Dependencies') { steps { sh ''' set -e + cd "$WORKSPACE" - # ── Create venv ──────────────────────────────────── + # Crea el venv python3 -m venv venv - # ── Upgrade pip toolchain ────────────────────────── - . venv/bin/activate - pip install --upgrade pip wheel setuptools + # Usa sempre python3 -m pip, mai el binari pip directament + "$WORKSPACE/venv/bin/python3" -m pip install --upgrade pip wheel setuptools - # ── Core dependencies ────────────────────────────── - pip install -U \ + "$WORKSPACE/venv/bin/python3" -m pip install -U \ atproto \ playwright \ playwright-stealth \ @@ -50,44 +43,19 @@ pipeline { beautifulsoup4 \ charset-normalizer \ Pillow \ - grapheme + grapheme \ + yt-dlp \ + curl-cffi - # ── yt-dlp: always upgrade to latest ────────────── - # TikTok extractor breaks frequently — latest is required - pip install --upgrade yt-dlp - pip show yt-dlp | grep -E "^(Name|Version)" + # Sanity checks + "$WORKSPACE/venv/bin/python3" -c "import atproto; print('atproto OK')" + "$WORKSPACE/venv/bin/python3" -c "import playwright; print('playwright OK')" + "$WORKSPACE/venv/bin/python3" -c "import yt_dlp; print('yt_dlp OK')" + "$WORKSPACE/venv/bin/python3" -c "import curl_cffi; print('curl_cffi OK')" - # ── curl_cffi: TikTok impersonation (REQUIRED) ───── - # 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 version check ─────────────── - pip show playwright-stealth | grep -E "^(Name|Version)" - python3 -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 ────────────────────────────────── - python3 -c "import atproto; print('atproto OK')" - python3 -c "import playwright; print('playwright OK')" - python3 -c "import yt_dlp; print('yt_dlp OK')" - python3 -c "import httpx; print('httpx OK')" - python3 -c "import arrow; print('arrow OK')" - python3 -c "import moviepy; print('moviepy OK')" - - # ── System tools ─────────────────────────────────── - ffmpeg -version | head -1 - ffprobe -version | head -1 - - # ── Playwright browser binaries ──────────────────── - playwright install chromium + # Playwright browser binaries + PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \ + "$WORKSPACE/venv/bin/python3" -m playwright install chromium ''' } }