Actualizar Jenkinsfile.ci
This commit is contained in:
@@ -57,7 +57,7 @@ pipeline {
|
|||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install -r requirements-dev.txt
|
pip install -r requirements-dev.txt
|
||||||
ruff check app tests
|
ruff check app tests
|
||||||
pytest -o cache_dir="$WORKSPACE/.cache/pytest"
|
pytest -o cache_dir="$WORKSPACE/.cache/pytest" --junitxml=pytest.xml
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,41 +93,18 @@ pipeline {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
script {
|
script {
|
||||||
node {
|
node {
|
||||||
junit testResults: 'backend/pytest.xml', allowEmptyResults: true
|
junit testResults: 'backend/pytest.xml', allowEmptyResults: true
|
||||||
|
|
||||||
try {
|
|
||||||
if (env.CHANGE_ID) {
|
if (env.CHANGE_ID) {
|
||||||
def owner = null
|
def giteaBase = 'https://openbokeron.org'
|
||||||
def repo = null
|
def owner = 'OpenBokeron'
|
||||||
def giteaBase = null
|
def repo = 'TallerCiCd'
|
||||||
|
|
||||||
if (env.CHANGE_URL) {
|
|
||||||
def u = new URL(env.CHANGE_URL)
|
|
||||||
giteaBase = "${u.protocol}://${u.host}"
|
|
||||||
def path = u.path // /gitea/OpenBokeron/TallerCiCd/pulls/29
|
|
||||||
def m = (path =~ /\/gitea\/([^\/]+)\/([^\/]+)\/pulls\/\d+/)
|
|
||||||
if (m) {
|
|
||||||
owner = m[0][1]
|
|
||||||
repo = m[0][2]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!owner || !repo) && env.GIT_URL) {
|
|
||||||
def m = (env.GIT_URL =~ /[:\/]([^\/:]+)\/([^\/]+?)(?:\.git)?$/)
|
|
||||||
if (m) {
|
|
||||||
owner = m[0][1]
|
|
||||||
repo = m[0][2]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!giteaBase) giteaBase = 'https://openbokeron.org' // AJUSTA si hace falta
|
|
||||||
}
|
|
||||||
|
|
||||||
if (owner && repo && giteaBase) {
|
|
||||||
def pr = env.CHANGE_ID
|
def pr = env.CHANGE_ID
|
||||||
|
|
||||||
def result = currentBuild.currentResult
|
def result = currentBuild.currentResult
|
||||||
def emoji = (result == 'SUCCESS') ? '✅' : (result == 'UNSTABLE') ? '⚠️' : '❌'
|
def emoji = (result == 'SUCCESS') ? '✅' : (result == 'UNSTABLE') ? '⚠️' : '❌'
|
||||||
|
|
||||||
@@ -137,7 +114,7 @@ pipeline {
|
|||||||
"- Commit: `${env.GIT_COMMIT?.take(7) ?: env.COMMIT_SHORT}`\\n" +
|
"- Commit: `${env.GIT_COMMIT?.take(7) ?: env.COMMIT_SHORT}`\\n" +
|
||||||
"- URL: ${env.BUILD_URL}"
|
"- URL: ${env.BUILD_URL}"
|
||||||
|
|
||||||
def url = "${giteaBase}/gitea/api/v1/repos/${owner}/${repo}/issues/${pr}/comments"
|
def commentsUrl = "${giteaBase}/gitea/api/v1/repos/${owner}/${repo}/issues/${pr}/comments"
|
||||||
|
|
||||||
withCredentials([string(credentialsId: 'gitea-jenkins-bot-token', variable: 'GITEA_TOKEN')]) {
|
withCredentials([string(credentialsId: 'gitea-jenkins-bot-token', variable: 'GITEA_TOKEN')]) {
|
||||||
sh """
|
sh """
|
||||||
@@ -146,26 +123,20 @@ pipeline {
|
|||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data @- \
|
--data @- \
|
||||||
'${url}' <<'JSON'
|
'${commentsUrl}' <<'JSON'
|
||||||
{"body":"${msg.replace('\\', '\\\\').replace('"','\\"')}"}
|
{"body":"${msg.replace('\\', '\\\\').replace('"','\\"')}"}
|
||||||
JSON
|
JSON
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
echo "Comentado en PR #${pr} (${owner}/${repo})."
|
|
||||||
} else {
|
|
||||||
echo "No pude deducir owner/repo/baseURL; no comento en la PR."
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
echo "No es build de PR (CHANGE_ID vacío); no comento."
|
echo "No es build de PR (CHANGE_ID vacío); no comento."
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
echo "Fallo al comentar en PR: ${err}"
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanWs()
|
cleanWs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user