From 7b8e1404214561bfaa47ec7bb50e2f8856b77539 Mon Sep 17 00:00:00 2001 From: 12ww1160 <12ww1160@confdroid.com> Date: Sat, 13 Jun 2026 14:27:04 +0200 Subject: [PATCH 1/3] OP#618 add ssh-agent to last stage --- Jenkinsfile | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8647b2c..bceb0d9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -107,36 +107,25 @@ pipeline { } stage('Mirror to Gitea') { steps { + sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) { withCredentials([usernamePassword( - credentialsId: 'Jenkins-gitea', - usernameVariable: 'GITEA_USER', - passwordVariable: 'GITEA_TOKEN')]) { - script { - sh ''' - git fetch --tags origin - git checkout -B gitea-mirror-$BUILD_NUMBER origin/master - git rm -f Jenkinsfile - git commit -m "Remove Jenkinsfile for Gitea mirror" || echo "No changes to commit" - git remote get-url master >/dev/null 2>&1 \ - && git remote set-url master https://sourcecode.confdroid.com/confdroid/confdroid_java.git \ - || git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_java.git - git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ - push --force master HEAD:refs/heads/master - git ls-remote --heads master | awk '{print $2}' | sed 's#refs/heads/##' | while read branch; do - if [ -n "$branch" ] && [ "$branch" != "master" ]; then - git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ - push master --delete "$branch" - fi - done - git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ - push master --tags - git ls-remote --tags master | awk '{print $2}' | sed 's#refs/tags/##' | cut -d'^' -f1 | sort -u | while read tag; do - if [ -n "$tag" ] && ! git show-ref --tags --verify --quiet "refs/tags/$tag"; then - git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ - push master ":refs/tags/$tag" - fi - done - ''' + credentialsId: 'Jenkins-gitea', + usernameVariable: 'GITEA_USER', + passwordVariable: 'GITEA_TOKEN')]) { + script { + // Checkout from GitLab (already done implicitly) + sh ''' + git checkout master + git pull origin master + git branch -D development + git branch -D jenkins-build-$BUILD_NUMBER + git rm -f Jenkinsfile + git rm -r --cached .vscode || echo "No .vscode to remove from git" + git commit --amend --no-edit --allow-empty + git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_java.git + git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ + push master --mirror + ''' } } } From 4777a52c96d85616719fc45c46d61093370de486 Mon Sep 17 00:00:00 2001 From: 12ww1160 <12ww1160@confdroid.com> Date: Sat, 13 Jun 2026 14:29:13 +0200 Subject: [PATCH 2/3] OP#618 add ssh-agent to last stage --- Jenkinsfile | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bceb0d9..7520e8e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -108,24 +108,24 @@ pipeline { stage('Mirror to Gitea') { steps { sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) { - withCredentials([usernamePassword( - credentialsId: 'Jenkins-gitea', - usernameVariable: 'GITEA_USER', - passwordVariable: 'GITEA_TOKEN')]) { - script { - // Checkout from GitLab (already done implicitly) - sh ''' - git checkout master - git pull origin master - git branch -D development - git branch -D jenkins-build-$BUILD_NUMBER - git rm -f Jenkinsfile - git rm -r --cached .vscode || echo "No .vscode to remove from git" - git commit --amend --no-edit --allow-empty - git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_java.git - git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ - push master --mirror - ''' + withCredentials([usernamePassword( + credentialsId: 'Jenkins-gitea', + usernameVariable: 'GITEA_USER', + passwordVariable: 'GITEA_TOKEN')]) { + script { + // Checkout from GitLab (already done implicitly) + sh ''' + git checkout master + git pull origin master + git branch -D development + git branch -D jenkins-build-$BUILD_NUMBER + git rm -f Jenkinsfile + git rm -r --cached .vscode || echo "No .vscode to remove from git" + git commit --amend --no-edit --allow-empty + git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_java.git + git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ + push master --mirror + ''' } } } From 427d032215da149f58f3efd193793e5f84e99543 Mon Sep 17 00:00:00 2001 From: 12ww1160 <12ww1160@confdroid.com> Date: Sat, 13 Jun 2026 14:30:36 +0200 Subject: [PATCH 3/3] OP#618 add ssh-agent to last stage --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 7520e8e..b24c6ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -126,6 +126,7 @@ pipeline { git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ push master --mirror ''' + } } } }