Spaces:
Sleeping
Sleeping
File size: 2,387 Bytes
70d4931 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | 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
if ! command -v hf &> /dev/null; then
pip3 install --user -U huggingface_hub
fi
'''
}
}
stage('Authenticate Hugging Face') {
steps {
echo "π Logging into Hugging Face..."
sh '''#!/bin/bash
set -e
export PATH=$HOME/.local/bin:$PATH
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
hf repos create "$HF_USERNAME/$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
hf upload "$HF_USERNAME/$SPACE_NAME" . --repo-type=space
'''
}
}
}
post {
success {
echo "β
Pipeline executed successfully!"
}
failure {
echo "β Pipeline failed!"
}
}
} |