refactor(jenkins): remove redundant Checkout stage
Declarative Pipeline with agent any already runs 'Declarative: Checkout SCM'
automatically before user stages the explicit stage('Checkout') was cloning
the repo a second time for no reason. Remove it entirely; capture GIT_COMMIT_SHA
and GIT_PREV_SHA at the top of stage('Detect') using the already-present workspace.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
37
ci/Jenkinsfile
vendored
37
ci/Jenkinsfile
vendored
@@ -119,42 +119,21 @@ pipeline {
|
|||||||
stages {
|
stages {
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
* STAGE 1 — Checkout
|
* STAGE 1 — Detect changed addons
|
||||||
* ------------------------------------------------------------------- */
|
|
||||||
stage('Checkout') {
|
|
||||||
steps {
|
|
||||||
checkout([
|
|
||||||
$class: 'GitSCM',
|
|
||||||
branches: [[name: '*/main']],
|
|
||||||
userRemoteConfigs: [[
|
|
||||||
url: "${env.GITEA_BASE_URL}/${params.GITEA_USER}/HomeAssistantAddOns.git",
|
|
||||||
credentialsId: 'gitea-credentials'
|
|
||||||
]],
|
|
||||||
// Fetch completo: serve per il diff tra commit consecutivi
|
|
||||||
extensions: [
|
|
||||||
[$class: 'CloneOption', depth: 0, shallow: false, noTags: false]
|
|
||||||
]
|
|
||||||
])
|
|
||||||
script {
|
|
||||||
env.GIT_COMMIT_SHA = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
|
||||||
env.GIT_PREV_SHA = sh(script: 'git rev-parse HEAD~1', returnStdout: true).trim()
|
|
||||||
echo "[INFO] HEAD : ${env.GIT_COMMIT_SHA}"
|
|
||||||
echo "[INFO] HEAD~1 : ${env.GIT_PREV_SHA}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
|
||||||
* STAGE 2 — Detect changed addons
|
|
||||||
*
|
*
|
||||||
|
* Il checkout è già fatto da "Declarative: Checkout SCM" automatico.
|
||||||
* Un addon valido è una sotto-directory della root che contiene
|
* Un addon valido è una sotto-directory della root che contiene
|
||||||
* config.yaml oppure config.json (standard HA Supervisor).
|
* config.yaml oppure config.json (standard HA Supervisor).
|
||||||
* Quando il trigger è il webhook usa i SHA before/after iniettati
|
|
||||||
* dal Generic Webhook Trigger; altrimenti HEAD~1..HEAD.
|
|
||||||
* ------------------------------------------------------------------- */
|
* ------------------------------------------------------------------- */
|
||||||
stage('Detect') {
|
stage('Detect') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
|
// SHA del commit corrente e del precedente (già nel workspace)
|
||||||
|
env.GIT_COMMIT_SHA = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
|
||||||
|
env.GIT_PREV_SHA = sh(script: 'git rev-parse HEAD~1', returnStdout: true).trim()
|
||||||
|
echo "[INFO] HEAD : ${env.GIT_COMMIT_SHA}"
|
||||||
|
echo "[INFO] HEAD~1 : ${env.GIT_PREV_SHA}"
|
||||||
|
|
||||||
// Tutti gli addon presenti nel workspace (indipendentemente da cosa è cambiato)
|
// Tutti gli addon presenti nel workspace (indipendentemente da cosa è cambiato)
|
||||||
def allAddons = sh(
|
def allAddons = sh(
|
||||||
script: '''
|
script: '''
|
||||||
|
|||||||
Reference in New Issue
Block a user