-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
48 lines (48 loc) · 1.63 KB
/
Jenkinsfile
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
pipeline {
agent { label 'builtin' }
environment {
GITEA_CREDS = credentials('AMARILLO-JENKINS-GITEA-USER')
PYPI_CREDS = credentials('AMARILLO-JENKINS-PYPI-USER')
TWINE_REPO_URL = "https://git.gerhardt.io/api/packages/amarillo/pypi"
}
stages {
stage('Create virtual environment') {
steps {
echo 'Creating virtual environment'
sh '''python3 -m venv .venv
. .venv/bin/activate'''
}
}
stage('Installing requirements') {
steps {
echo 'Installing packages'
sh 'python3 -m pip install -r requirements.txt'
sh 'python3 -m pip install --upgrade build'
sh 'python3 -m pip install --upgrade twine'
}
}
stage('Build') {
steps {
echo 'Cleaning up dist directory'
dir("dist") {
deleteDir()
}
echo 'Building package'
sh 'python3 -m build'
}
}
stage('Publish package to GI') {
steps {
sh 'python3 -m twine upload --skip-existing --verbose --repository-url $TWINE_REPO_URL --username $GITEA_CREDS_USR --password $GITEA_CREDS_PSW ./dist/*'
}
}
stage('Publish package to PyPI') {
when {
branch 'main'
}
steps {
sh 'python3 -m twine upload --skip-existing --verbose --username $PYPI_CREDS_USR --password $PYPI_CREDS_PSW ./dist/*'
}
}
}
}