From aaaae1a793f55b96cee0afa5842c78740441829b Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 13:50:39 +0100 Subject: [PATCH 01/16] Test Jenkinsfile with echo commands --- Jenkinsfile | 39 +++++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..40999ab --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,39 @@ +pipeline { + agent any + + stages { + stage('Build') { + steps { + echo 'Building' + } + } + stage('Test') { + steps { + echo 'Testing' + } + } + stage('Deploy') { + steps { + echo 'Deploying' + } + } + } + post { + always { + echo 'This will always run' + } + success { + echo 'This will run only if successful' + } + failure { + echo 'This will run only if failed' + } + unstable { + echo 'This will run only if the run was marked as unstable' + } + changed { + echo 'This will run only if the state of the Pipeline has changed' + echo 'For example, if the Pipeline was previously failing but is now successful' + } + } +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index eed1c3c..861fb36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "amarillo-core" -version = "0.0.4" +version = "0.0.5" dependencies = [ "fastapi[all]==0.104.0", "geopandas==0.14", -- 2.30.2 From d1b9cfdf430b55901764d2c87b78c07143ce69ad Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 13:59:47 +0100 Subject: [PATCH 02/16] Check if python is installed --- Jenkinsfile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 40999ab..a074272 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,17 @@ pipeline { agent any stages { + stage('Check python version') { + steps { + sh 'python --version' + } + } + stage('Run ls and pwd') { + steps { + sh 'pwd' + sh 'ls -l' + } + } stage('Build') { steps { echo 'Building' -- 2.30.2 From a6111cd039c0941b0e66fcf660dc9e284247bfe1 Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 14:10:30 +0100 Subject: [PATCH 03/16] Python3 docker agent --- Jenkinsfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a074272..f344bc5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,10 @@ pipeline { - agent any - + agent { + docker { + image 'python:3' + label 'amarillo-build-agent' + } + } stages { stage('Check python version') { steps { -- 2.30.2 From 32f4eac11f0a2514e8c1078c39b1bad32d95b7e9 Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 14:18:44 +0100 Subject: [PATCH 04/16] Removed node label --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f344bc5..eb30ed1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,6 @@ pipeline { agent { docker { image 'python:3' - label 'amarillo-build-agent' } } stages { -- 2.30.2 From f0a67bf4ea6fa7652e476d90795b5c1da46112cd Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 14:52:13 +0100 Subject: [PATCH 05/16] Added docker to tools --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index eb30ed1..2c7dcb7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,9 @@ pipeline { image 'python:3' } } + tools { + 'org.jenkinsci.plugins.docker.commons.tools.DockerTool' 'docker' + } stages { stage('Check python version') { steps { -- 2.30.2 From b19d2e9dbb2f3ae61b839112315aa0fdda9ede1f Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 15:50:15 +0100 Subject: [PATCH 06/16] Create virtual environment --- Jenkinsfile | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2c7dcb7..7c8c51b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,26 +4,21 @@ pipeline { image 'python:3' } } - tools { - 'org.jenkinsci.plugins.docker.commons.tools.DockerTool' 'docker' - } stages { - stage('Check python version') { + stage('Create virtual environment') { steps { - sh 'python --version' - } - } - stage('Run ls and pwd') { - steps { - sh 'pwd' - sh 'ls -l' - } - } - stage('Build') { - steps { - echo 'Building' + echo 'Creating virtual environment' + sh '''python -m venv .venv + . venv/bin/activate''' + } } + // stage('pip install') { + // steps { + // echo 'Installing packages' + // sh 'pip ins' + // } + // } stage('Test') { steps { echo 'Testing' -- 2.30.2 From e1b0b04582878da8878604a2ef79fee50e6de0d6 Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 15:54:30 +0100 Subject: [PATCH 07/16] Install packages --- Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7c8c51b..b287500 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,16 +9,16 @@ pipeline { steps { echo 'Creating virtual environment' sh '''python -m venv .venv - . venv/bin/activate''' + . .venv/bin/activate''' } } - // stage('pip install') { - // steps { - // echo 'Installing packages' - // sh 'pip ins' - // } - // } + stage('Installing requirements') { + steps { + echo 'Installing packages' + sh 'pip install -r requirements.txt' + } + } stage('Test') { steps { echo 'Testing' -- 2.30.2 From eaf6c94599a8876fd22a5d3d65447e996687edb5 Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 16:08:13 +0100 Subject: [PATCH 08/16] Trying 'python -m pip' --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b287500..2a2f6c9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ pipeline { stage('Installing requirements') { steps { echo 'Installing packages' - sh 'pip install -r requirements.txt' + sh 'python -m pip install -r requirements.txt' } } stage('Test') { -- 2.30.2 From 4499c125c4aca00ac23fc64a8c153d9c4f3ea06c Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 16:15:04 +0100 Subject: [PATCH 09/16] Specify jenkins user --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 2a2f6c9..d9e9baf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,6 +2,7 @@ pipeline { agent { docker { image 'python:3' + user 'jenkins' } } stages { -- 2.30.2 From 1b164159aaea3227232da62acb1cbdf2825dbd6c Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 16:17:03 +0100 Subject: [PATCH 10/16] Specify jenkins user --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d9e9baf..b0284ef 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent { docker { image 'python:3' - user 'jenkins' + args '-u jenkins' } } stages { -- 2.30.2 From 6ddbd513f10ed0c2ff3d0d6709a3d77182023b42 Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Wed, 13 Dec 2023 16:19:06 +0100 Subject: [PATCH 11/16] Run as root --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b0284ef..b0694fc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent { docker { image 'python:3' - args '-u jenkins' + args '-u root' } } stages { -- 2.30.2 From cb501cc2a9e7cb301a4fed4a14350aca59567fb8 Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Fri, 15 Dec 2023 14:23:33 +0100 Subject: [PATCH 12/16] Build and publish package --- Jenkinsfile | 13 +++++++++++-- pyproject.toml | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b0694fc..c2235c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,6 +5,9 @@ pipeline { args '-u root' } } + environment { + GITEA_CREDS = credentials('AMARILLO-JENKINS-GITEA-USER') + } stages { stage('Create virtual environment') { steps { @@ -25,9 +28,15 @@ pipeline { echo 'Testing' } } - stage('Deploy') { + stage('Build') { steps { - echo 'Deploying' + echo 'Building package' + sh 'python -m build' + } + } + stage('Publish package') { + steps { + sh 'python -m twine upload --repository gitea --username $GITEA_CREDS_USR --password $GITEA_CREDS_PSW ./dist/*' } } } diff --git a/pyproject.toml b/pyproject.toml index 861fb36..a9358b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "amarillo-core" -version = "0.0.5" +version = "0.0.6" dependencies = [ "fastapi[all]==0.104.0", "geopandas==0.14", -- 2.30.2 From 07617451801c9a5cc99fed97427eb4e6b1a6b8aa Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Fri, 15 Dec 2023 14:28:25 +0100 Subject: [PATCH 13/16] pip install build --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index c2235c5..f0ae3e5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,6 +21,7 @@ pipeline { steps { echo 'Installing packages' sh 'python -m pip install -r requirements.txt' + sh 'python -m pip install --upgrade build' } } stage('Test') { -- 2.30.2 From 89c37aca22834d9552a787e8601e19d2cbe49c95 Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Fri, 15 Dec 2023 14:30:46 +0100 Subject: [PATCH 14/16] pip install twine --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index f0ae3e5..67dc011 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,6 +22,7 @@ pipeline { echo 'Installing packages' sh 'python -m pip install -r requirements.txt' sh 'python -m pip install --upgrade build' + sh 'python -m pip install --upgrade twine' } } stage('Test') { -- 2.30.2 From c154a463fd81115e01d0afec68bc87d90384ae90 Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Fri, 15 Dec 2023 14:49:47 +0100 Subject: [PATCH 15/16] Twine repo url --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 67dc011..ff194d0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,6 +7,7 @@ pipeline { } environment { GITEA_CREDS = credentials('AMARILLO-JENKINS-GITEA-USER') + TWINE_REPO_URL = "https://git.gerhardt.io/api/packages/amarillo/pypi" } stages { stage('Create virtual environment') { @@ -38,7 +39,7 @@ pipeline { } stage('Publish package') { steps { - sh 'python -m twine upload --repository gitea --username $GITEA_CREDS_USR --password $GITEA_CREDS_PSW ./dist/*' + sh 'python -m twine upload --repository-url $TWINE_REPO_URL --username $GITEA_CREDS_USR --password $GITEA_CREDS_PSW ./dist/*' } } } -- 2.30.2 From b5929ed3c0311c56af44106856ce7889f91cfe9d Mon Sep 17 00:00:00 2001 From: Francia Csaba Date: Mon, 18 Dec 2023 12:49:42 +0100 Subject: [PATCH 16/16] Bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a9358b9..87eb960 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "amarillo-core" -version = "0.0.6" +version = "0.0.7" dependencies = [ "fastapi[all]==0.104.0", "geopandas==0.14", -- 2.30.2