Multi-Rag / jenkins
VashuTheGreat2's picture
Upload folder using huggingface_hub
cc6674e verified
Raw
History Blame Contribute Delete
2.45 kB
pipeline {
agent any
environment {
REPO_URL = "https://github.com/VashuTheGreat/Multi-Rag.git"
PROJECT_NAME = "Multi-Rag"
SPACE_NAME="Multi-Rag"
HF_USERNAME="VashuTheGreat2"
HF_TOKEN = credentials('HF_TOKEN')
}
stages {
stage('Clone Repository') {
steps {
echo "πŸ“₯ Cloning repository..."
git branch: 'main', url: "${REPO_URL}"
}
}
stage('Setup Dependencies') {
steps {
echo "πŸ”§ Setting git identity and installing HF CLI..."
sh '''#!/bin/bash
set -e
git config --global user.name "jenkins"
git config --global user.email "jenkins@local"
export PATH=$HOME/.local/bin:$PATH
pip3 install --user --break-system-packages -U "huggingface_hub[cli]"
'''
}
}
stage('Authenticate Hugging Face') {
steps {
echo "πŸ” Logging into Hugging Face..."
sh '''#!/bin/bash
set -e
export PATH=$HOME/.local/bin:$PATH
python3 -m huggingface_hub.cli.hf auth login --token "$HF_TOKEN"
'''
}
}
stage('Configure Space Meta') {
steps {
echo "πŸ“ Injecting HF Spaces configuration into README.md..."
sh '''#!/bin/bash
set -e
TEMP_README=$(mktemp)
cat << EOF > "$TEMP_README"
---
title: $PROJECT_NAME
emoji: πŸ€–
colorFrom: blue
colorTo: green
sdk: docker
app_file: main.py
pinned: false
short_description: This is the Multi-Rag Agent
---
EOF
cat README.md >> "$TEMP_README"
mv "$TEMP_README" README.md
'''
}
}
stage('Create App Space') {
steps {
echo "πŸš€ Creating HF Space if it doesn't exist..."
sh '''#!/bin/bash
set -e
export PATH=$HOME/.local/bin:$PATH
python3 -m huggingface_hub.cli.hf repos create "$SPACE_NAME" --type space --space-sdk docker || true
'''
}
}
stage('Upload to HF Space') {
steps {
echo "πŸ“€ Uploading project files..."
sh '''#!/bin/bash
set -e
export PATH=$HOME/.local/bin:$PATH
python3 -m huggingface_hub.cli.hf upload "$HF_USERNAME/$SPACE_NAME" . --repo-type space
'''
}
}
}
post {
success {
echo "βœ… Pipeline executed successfully!"
}
failure {
echo "❌ Pipeline failed!"
}
}
}