Changed post logic of pipeline
parent
c23c437abb
commit
fb3db62728
|
|
@ -130,6 +130,9 @@ EOF
|
|||
|
||||
createDebPackage("amd64", targetDirAmd, env.WORKSPACE, env.INSTALL_SIZE_AMD)
|
||||
createDebPackage("riscv64", targetDirRisc, env.WORKSPACE, env.INSTALL_SIZE_RISC)
|
||||
|
||||
env.DEB_PATH_AMD64 = "${env.WORKSPACE}/rc/amd64/${packageName}_${version}_amd64.deb"
|
||||
env.DEB_PATH_RISCV64 = "${env.WORKSPACE}/rc/riscv64/${packageName}_${version}_riscv64.deb"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -157,13 +160,14 @@ EOF
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Upload Debs to Repository') {
|
||||
when {
|
||||
expression { env.CHANGE_BRANCH?.startsWith('rc') }
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
echo "Uploading deb packag1es to remote repository..."
|
||||
echo "Uploading deb packages to remote repository..."
|
||||
|
||||
withCredentials([usernamePassword(credentialsId: 'prod', passwordVariable: 'SSH_PASS', usernameVariable: 'SSH_USER')]) {
|
||||
def remote = [:]
|
||||
|
|
@ -174,47 +178,66 @@ EOF
|
|||
remote.allowAnyHosts = true
|
||||
|
||||
echo "Uploading deb packages using sshPut..."
|
||||
|
||||
sshPut remote: remote, from: "${env.WORKSPACE}/rc/amd64/*", into: "/home/user/repo/debs/"
|
||||
sshPut remote: remote, from: "${env.WORKSPACE}/rc/riscv64/*", into: "/home/user/repo/debs/"
|
||||
sshPut remote: remote, from: "${env.DEB_PATH_AMD64}", into: "/home/user/repo/debs/"
|
||||
sshPut remote: remote, from: "${env.DEB_PATH_RISCV64}", into: "/home/user/repo/debs/"
|
||||
|
||||
echo "Running repository update commands via sshCommand..."
|
||||
|
||||
sshCommand remote: remote, command: """
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
cd /home/user/repo/debs/
|
||||
reprepro --priority optional --section utils includedeb stable *.deb
|
||||
for deb in *.deb; do
|
||||
reprepro --priority optional --section utils includedeb stable "$deb"
|
||||
done
|
||||
rm -f *.deb
|
||||
"""
|
||||
|
||||
echo "Deb packages successfully uploaded and added to the repository!"
|
||||
}
|
||||
sh "rm -rf ${env.WORKSPACE}/package/"
|
||||
sh "rm -rf ${env.WORKSPACE}/rc/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Merge Pull Request') {
|
||||
when {
|
||||
expression { env.CHANGE_BRANCH?.startsWith('rc') }
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
echo "Attempting to merge PR ${env.CHANGE_ID} using credentials ..."
|
||||
withCredentials([usernamePassword(credentialsId: 'Jenkins creds', usernameVariable: 'GITEA_USER', passwordVariable: 'GITEA_PASS')]) {
|
||||
def prId = env.CHANGE_ID
|
||||
sh """
|
||||
curl -X POST \
|
||||
-u "${GITEA_USER}:${GITEA_PASS}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"Do":"merge"}' \
|
||||
http://git.entcor/api/v1/repos/VladislavD/runner-rs/pulls/${prId}/merge
|
||||
"""
|
||||
echo "PR ${prId} merged successfully!"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
echo "Cleaning up workspace..."
|
||||
try {
|
||||
if (fileExists("${env.WORKSPACE}/package/")) {
|
||||
sh "rm -rf ${env.WORKSPACE}/package/"
|
||||
}
|
||||
if (fileExists("${env.WORKSPACE}/rc/")) {
|
||||
sh "rm -rf ${env.WORKSPACE}/rc/"
|
||||
}
|
||||
} catch (Exception e) {
|
||||
echo "Failed to clean up workspace: ${e}"
|
||||
}
|
||||
}
|
||||
}
|
||||
success {
|
||||
script {
|
||||
when {
|
||||
expression { env.CHANGE_BRANCH?.startsWith('rc') }
|
||||
}
|
||||
echo "Attempting to merge PR ${env.CHANGE_ID} into master..."
|
||||
withCredentials([usernamePassword(credentialsId: 'Jenkins creds', usernameVariable: 'GITEA_USER', passwordVariable: 'GITEA_PASS')]) {
|
||||
def prId = env.CHANGE_ID
|
||||
sh """
|
||||
curl -X POST \
|
||||
-u "${GITEA_USER}:${GITEA_PASS}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"Do":"merge"}' \
|
||||
http://git.entcor/api/v1/repos/VladislavD/runner-rs/pulls/${prId}/merge
|
||||
"""
|
||||
echo "PR ${prId} merged successfully into master!"
|
||||
}
|
||||
}
|
||||
}
|
||||
failure {
|
||||
echo "Pipeline failed. Check the logs for details."
|
||||
}
|
||||
aborted {
|
||||
echo "Pipeline was aborted."
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue