93 lines
3.6 KiB
Plaintext
93 lines
3.6 KiB
Plaintext
pipeline {
|
|
agent any
|
|
|
|
options {
|
|
timeout(time: 15, 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"
|
|
|
|
# Crea el venv
|
|
python3 -m venv venv
|
|
|
|
# Usa python3 -m pip per evitar problemes de shebang amb sh/dash
|
|
"$WORKSPACE/venv/bin/python3" -m pip install --upgrade pip wheel setuptools
|
|
|
|
"$WORKSPACE/venv/bin/python3" -m pip install -U \
|
|
atproto \
|
|
tweety-ns \
|
|
playwright \
|
|
httpx \
|
|
arrow \
|
|
python-dotenv \
|
|
moviepy \
|
|
grapheme
|
|
|
|
# Verificació moviepy
|
|
"$WORKSPACE/venv/bin/python3" -m pip list | grep moviepy \
|
|
|| { echo 'MoviePy installation failed!'; exit 1; }
|
|
|
|
# Verificació FFmpeg
|
|
ffmpeg -version \
|
|
|| { echo 'FFmpeg is not installed!'; exit 1; }
|
|
|
|
# Verificació imports
|
|
"$WORKSPACE/venv/bin/python3" -c "import moviepy; print('moviepy OK')"
|
|
"$WORKSPACE/venv/bin/python3" -c "import atproto; print('atproto OK')"
|
|
"$WORKSPACE/venv/bin/python3" -c "import playwright; print('playwright OK')"
|
|
|
|
# Instal·lació binaris Playwright
|
|
PLAYWRIGHT_BROWSERS_PATH=/var/jenkins_home/.playwright-browsers \
|
|
"$WORKSPACE/venv/bin/python3" -m playwright install chromium
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Run Script') {
|
|
steps {
|
|
// Securely injects Jenkins credentials as environment variables
|
|
withCredentials([
|
|
string(credentialsId: 'TWITTER_USERNAME', variable: 'TWITTER_USERNAME'),
|
|
string(credentialsId: 'TWITTER_PASSWORD', variable: 'TWITTER_PASSWORD'),
|
|
string(credentialsId: 'TWITTER_BETEVE_EMAIL', variable: 'TWITTER_BETEVE_EMAIL'),
|
|
string(credentialsId: 'TWITTER_BTVESPORTS_HANDLE', variable: 'TWITTER_BTVESPORTS_HANDLE'),
|
|
string(credentialsId: 'BSKY_BETEVE_HANDLE', variable: 'BSKY_BETEVE_HANDLE'),
|
|
string(credentialsId: 'BSKY_BETEVE_APP_PASSWORD', variable: 'BSKY_BETEVE_APP_PASSWORD')
|
|
]) {
|
|
sh '''
|
|
# Activate the virtual environment and run the script
|
|
. venv/bin/activate && \
|
|
python3 twitter2bsky.py \
|
|
--twitter-username "$TWITTER_USERNAME" \
|
|
--twitter-password "$TWITTER_PASSWORD" \
|
|
--twitter-email "$TWITTER_BETEVE_EMAIL" \
|
|
--twitter-handle "$TWITTER_BTVESPORTS_HANDLE" \
|
|
--bsky-handle "$BSKY_BETEVE_HANDLE" \
|
|
--bsky-password "$BSKY_BETEVE_APP_PASSWORD" \
|
|
--bsky-base-url https://eurosky.social \
|
|
--bsky-langs ca
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |