OP#618 add ssh-agent to last stage

This commit is contained in:
2026-06-13 14:27:04 +02:00
parent 92dd1c441d
commit 7b8e140421

47
Jenkinsfile vendored
View File

@@ -107,36 +107,25 @@ pipeline {
} }
stage('Mirror to Gitea') { stage('Mirror to Gitea') {
steps { steps {
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
withCredentials([usernamePassword( withCredentials([usernamePassword(
credentialsId: 'Jenkins-gitea', credentialsId: 'Jenkins-gitea',
usernameVariable: 'GITEA_USER', usernameVariable: 'GITEA_USER',
passwordVariable: 'GITEA_TOKEN')]) { passwordVariable: 'GITEA_TOKEN')]) {
script { script {
sh ''' // Checkout from GitLab (already done implicitly)
git fetch --tags origin sh '''
git checkout -B gitea-mirror-$BUILD_NUMBER origin/master git checkout master
git rm -f Jenkinsfile git pull origin master
git commit -m "Remove Jenkinsfile for Gitea mirror" || echo "No changes to commit" git branch -D development
git remote get-url master >/dev/null 2>&1 \ git branch -D jenkins-build-$BUILD_NUMBER
&& git remote set-url master https://sourcecode.confdroid.com/confdroid/confdroid_java.git \ git rm -f Jenkinsfile
|| git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_java.git git rm -r --cached .vscode || echo "No .vscode to remove from git"
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ git commit --amend --no-edit --allow-empty
push --force master HEAD:refs/heads/master git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_java.git
git ls-remote --heads master | awk '{print $2}' | sed 's#refs/heads/##' | while read branch; do git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
if [ -n "$branch" ] && [ "$branch" != "master" ]; then push master --mirror
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
'''
} }
} }
} }