OP#618 add ssh-agent to last stage
This commit is contained in:
62
Jenkinsfile
vendored
62
Jenkinsfile
vendored
@@ -108,36 +108,38 @@ pipeline {
|
|||||||
}
|
}
|
||||||
stage('Mirror to Gitea') {
|
stage('Mirror to Gitea') {
|
||||||
steps {
|
steps {
|
||||||
withCredentials([usernamePassword(
|
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
|
||||||
credentialsId: 'Jenkins-gitea',
|
withCredentials([usernamePassword(
|
||||||
usernameVariable: 'GITEA_USER',
|
credentialsId: 'Jenkins-gitea',
|
||||||
passwordVariable: 'GITEA_TOKEN')]) {
|
usernameVariable: 'GITEA_USER',
|
||||||
script {
|
passwordVariable: 'GITEA_TOKEN')]) {
|
||||||
sh '''
|
script {
|
||||||
git fetch --tags origin
|
sh '''
|
||||||
git checkout -B gitea-mirror-$BUILD_NUMBER origin/master
|
git fetch --tags origin
|
||||||
git rm -f Jenkinsfile
|
git checkout -B gitea-mirror-$BUILD_NUMBER origin/master
|
||||||
git commit -m "Remove Jenkinsfile for Gitea mirror" || echo "No changes to commit"
|
git rm -f Jenkinsfile
|
||||||
git remote get-url master >/dev/null 2>&1 \
|
git commit -m "Remove Jenkinsfile for Gitea mirror" || echo "No changes to commit"
|
||||||
&& git remote set-url master https://sourcecode.confdroid.com/confdroid/confdroid_jenkins.git \
|
git remote get-url master >/dev/null 2>&1 \
|
||||||
|| git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_jenkins.git
|
&& git remote set-url master https://sourcecode.confdroid.com/confdroid/confdroid_jenkins.git \
|
||||||
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
|| git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_jenkins.git
|
||||||
push --force master HEAD:refs/heads/master
|
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
||||||
git ls-remote --heads master | awk '{print $2}' | sed 's#refs/heads/##' | while read branch; do
|
push --force master HEAD:refs/heads/master
|
||||||
if [ -n "$branch" ] && [ "$branch" != "master" ]; then
|
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 --delete "$branch"
|
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
||||||
fi
|
push master --delete "$branch"
|
||||||
done
|
fi
|
||||||
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
done
|
||||||
push master --tags
|
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
||||||
git ls-remote --tags master | awk '{print $2}' | sed 's#refs/tags/##' | cut -d'^' -f1 | sort -u | while read tag; do
|
push master --tags
|
||||||
if [ -n "$tag" ] && ! git show-ref --tags --verify --quiet "refs/tags/$tag"; then
|
git ls-remote --tags master | awk '{print $2}' | sed 's#refs/tags/##' | cut -d'^' -f1 | sort -u | while read tag; do
|
||||||
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
if [ -n "$tag" ] && ! git show-ref --tags --verify --quiet "refs/tags/$tag"; then
|
||||||
push master ":refs/tags/$tag"
|
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
||||||
fi
|
push master ":refs/tags/$tag"
|
||||||
done
|
fi
|
||||||
'''
|
done
|
||||||
|
'''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user