From 2c87f5488d8e09b6e540893644ded3fc60be5320 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 19 Mar 2023 20:05:32 +0000 Subject: [PATCH 1/4] test: bump dev version --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f7466d0..d5327e5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -141,7 +141,7 @@ pipeline { stage("GetCode") { steps { dir("gitrepo") { - // manually checkout the repository, with All branches and tags + // manually checkout the repository, with All branches and tags // => because we might need them for version and changelog computing checkout([ $class: "GitSCM", branches: [[name: GIT_BRANCH]], -- 2.47.3 From cb213df6b6e449e4a686f495520b04c749a561d2 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 19 Mar 2023 20:44:31 +0000 Subject: [PATCH 2/4] fix: workaround for setuptools-git-versioning version guess --- Jenkinsfile | 59 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d5327e5..fb306e7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -135,6 +135,9 @@ pipeline { sh("git config --global user.email $_MaintainerEmail") sh("git config --global user.name $_MaintainerName") + withCredentials([usernamePassword(credentialsId: _SCMCredentials, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { + sh("git remote set-url origin https://${GIT_USERNAME}:${GIT_PASSWORD}@chacha.ddns.net/gitea/${_PROJECT_USER_NAME}/${_PROJECT_NAME}.git") + } } } @@ -148,6 +151,26 @@ pipeline { extensions: [[$class: "CloneOption", noTags: false, shallow: false, depth: 0, reference: '']], userRemoteConfigs: [[credentialsId: _SCMCredentials, url: GIT_URL]]]) script{ + // using git to get the latest tag on this branch (before processing) + def latestTag_beforeProcessing = sh(returnStdout: true, script: "git tag --sort=-creatordate | head -n 1").trim() + echo("latestTag_beforeProcessing:. . . . . . . . . . . . $latestTag ") + + sh(script: """#!/bin/sh - + |. ~/TOOLS_ENV/bin/activate + |exec python - << '__EOWRAPPER__' + | + |from pygitversionhelper import gitversionhelper + | + |print(f"most recent repository tag: {gitversionhelper.tag.getLastTag()}") + |print(f"most recent repository tag: {gitversionhelper.tag.getLastTag(same_branch=True)}") + |print(f"number of commit since last tag: {gitversionhelper.tag.getDistanceFromTag()}") + |print(f"number of commit since last tag: {gitversionhelper.tag.getDistanceFromTag(same_branch=True)}") + |print(f"most recent repository version: {gitversionhelper.version.getLastVersion(formated_output=True)}") + |print(f'current repository version: {gitversionhelper.version.getCurrentVersion(formated_output=True,version_std="PEP440",bump_type="dev",bump_dev_strategy="post")}') + | + |__EOWRAPPER__ + """.stripMargin()) + if(_GIT_BRANCH=="master") { if(sh(returnStdout: true, script: "git tag --points-at HEAD").trim().isEmpty()) @@ -176,20 +199,14 @@ pipeline { else { echo "new-tag requested in commit message: $BUMPED_VERSION" - withCredentials([usernamePassword(credentialsId: _SCMCredentials, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { - sh("git remote set-url origin https://${GIT_USERNAME}:${GIT_PASSWORD}@chacha.ddns.net/gitea/${_PROJECT_USER_NAME}/${_PROJECT_NAME}.git") - } + sh("git tag $BUMPED_VERSION") sh("git push origin --tags") } } } - - // using git to get the latest tag on this branch - def latestTag = sh(returnStdout: true, script: "git tag --sort=-creatordate | head -n 1").trim() - echo("latestTag:. . . . . . . . . . . . $latestTag ") - - sh(script: """#!/bin/sh - + + sh(script: """#!/bin/sh - |. ~/TOOLS_ENV/bin/activate |exec python - << '__EOWRAPPER__' | @@ -204,7 +221,20 @@ pipeline { | |__EOWRAPPER__ """.stripMargin()) - + + latestTag = sh(script: """#!/bin/sh - + |. ~/TOOLS_ENV/bin/activate + |exec python - << '__EOWRAPPER__' + | + |from pygitversionhelper import gitversionhelper + | + |print(gitversionhelper.tag.getLastTag(same_branch=True),end ="") + | + |__EOWRAPPER__ + """.stripMargin(), + returnStdout: true) + echo("latestTag:. . . . . . . . . . . . $latestTag ") + // get current (or bumped) version number from git history PY_PROJECT_VERSION = sh(script: """#!/bin/sh - |. ~/TOOLS_ENV/bin/activate @@ -220,11 +250,18 @@ pipeline { echo("PY_PROJECT_VERSION: . . . . . . . . . $PY_PROJECT_VERSION") PY_PROJECT_VERSION_STRIPPED=ExtractBaseVersion(PY_PROJECT_VERSION) + // Manually pushing a new tag with version string guessed by gitversionhelper + // because setuptools-git-versioning cant fing tag on other branches, so will guess a wring version without this tag. + if(latestTag!=PY_PROJECT_VERSION) + { + sh("git tag $PY_PROJECT_VERSION") + sh("git push origin --tags") + } + // specific handling to test the template itself // => little hacky... creating a new git repo with a commit/tag corresponding to HEAD of the official one if(_PROJECT_NAME=="pyChaChaDummyProject") //specific case to test the template itself { - sh("rm -Rf ~/_gitrepo || true") sh(script: """#!/bin/sh - -- 2.47.3 From 8ea6b43a73837cedd2aeb1320ee4b9432c8c36f9 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 19 Mar 2023 20:50:50 +0000 Subject: [PATCH 3/4] fix: git remote credentials --- Jenkinsfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fb306e7..0b6865f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -135,9 +135,7 @@ pipeline { sh("git config --global user.email $_MaintainerEmail") sh("git config --global user.name $_MaintainerName") - withCredentials([usernamePassword(credentialsId: _SCMCredentials, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { - sh("git remote set-url origin https://${GIT_USERNAME}:${GIT_PASSWORD}@chacha.ddns.net/gitea/${_PROJECT_USER_NAME}/${_PROJECT_NAME}.git") - } + } } @@ -151,6 +149,11 @@ pipeline { extensions: [[$class: "CloneOption", noTags: false, shallow: false, depth: 0, reference: '']], userRemoteConfigs: [[credentialsId: _SCMCredentials, url: GIT_URL]]]) script{ + + withCredentials([usernamePassword(credentialsId: _SCMCredentials, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) { + sh("git remote set-url origin https://${GIT_USERNAME}:${GIT_PASSWORD}@chacha.ddns.net/gitea/${_PROJECT_USER_NAME}/${_PROJECT_NAME}.git") + } + // using git to get the latest tag on this branch (before processing) def latestTag_beforeProcessing = sh(returnStdout: true, script: "git tag --sort=-creatordate | head -n 1").trim() echo("latestTag_beforeProcessing:. . . . . . . . . . . . $latestTag ") -- 2.47.3 From e226f1629286d632dd4fc5b7ad3410b9a9101e07 Mon Sep 17 00:00:00 2001 From: cclecle Date: Sun, 19 Mar 2023 20:54:02 +0000 Subject: [PATCH 4/4] fix: typo --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0b6865f..bddce1c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -156,7 +156,7 @@ pipeline { // using git to get the latest tag on this branch (before processing) def latestTag_beforeProcessing = sh(returnStdout: true, script: "git tag --sort=-creatordate | head -n 1").trim() - echo("latestTag_beforeProcessing:. . . . . . . . . . . . $latestTag ") + echo("latestTag_beforeProcessing:. . . . . . . . . . . . $latestTag_beforeProcessing") sh(script: """#!/bin/sh - |. ~/TOOLS_ENV/bin/activate -- 2.47.3