Files
post2bsky/jenkins/3CatEuforiaTikTok
Guillem Hernandez Sola 4342adc48a 3Cat TikTok
2026-06-30 15:44:34 +02:00

113 lines
3.9 KiB
Plaintext

pipeline {
agent any
options {
timeout(time: 20, unit: 'MINUTES')
timestamps()
buildDiscarder(logRotator(numToKeepStr: '10'))
disableConcurrentBuilds()
}
triggers {
cron('H/30 * * * *')
}
stages {
stage('Checkout Code') {
steps {
checkout scm
}
}
stage('Setup Python & Install Dependencies') {
steps {
sh '''
set -e
cd "$WORKSPACE"
python3 -m venv venv
"$WORKSPACE/venv/bin/pip" install --upgrade pip wheel setuptools
"$WORKSPACE/venv/bin/pip" install -U \
atproto \
playwright \
playwright-stealth \
httpx \
arrow \
python-dotenv \
moviepy \
beautifulsoup4 \
charset-normalizer \
Pillow \
grapheme \
yt-dlp \
curl-cffi
# 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')"
# Playwright browser binaries
PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \
"$WORKSPACE/venv/bin/playwright" install chromium
'''
}
}
stage('Run Script') {
steps {
withCredentials([
string(
credentialsId: 'TIKTOK_3CATEUFORIA_HANDLE',
variable: 'TIKTOK_3CATEUFORIA_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
cd "$WORKSPACE"
cp "$TIKTOK_COOKIES_FILE" tiktok_cookies.json
PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \
"$WORKSPACE/venv/bin/python3" tiktok2bsky.py \
--tiktok-handle "$TIKTOK_3CATEUFORIA_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 {
always {
archiveArtifacts(
artifacts: '*.log, *.json, screenshot_*.png',
allowEmptyArchive: true
)
sh 'rm -f "$WORKSPACE/tiktok_cookies.json" || true'
}
success { echo '✅ Sync cycle completed successfully.' }
failure { echo '❌ Sync cycle failed — check archived logs and screenshots.' }
unstable { echo '⚠️ Sync cycle finished with warnings.' }
}
}