#5311 Don't mix declarative and scripted pipeline
Merged 2 years ago by pingou. Opened 2 years ago by zlopez.
zlopez/pagure ci  into  master

file modified
+44 -48
@@ -25,64 +25,60 @@ 

      sh 'rsync -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root " -Ha --include=' +  rsyncpath +  " ${DUFFY_NODE}.ci.centos.org:~/ ./"

  }

  

- agent {

-     node('pagure') {

+ node('cico-workspace') {

  

-         label 'cico-workspace'

- 

-         properties([

-                 parameters([

-                     string(defaultValue: "", description: "", name: "REPO"),

-                     string(defaultValue: "", description: "", name: "BRANCH"),

-                     ])

+     properties([

+             parameters([

+                 string(defaultValue: "", description: "", name: "REPO"),

+                 string(defaultValue: "", description: "", name: "BRANCH"),

                  ])

+             ])

+ 

+     stage('Allocate Node'){

+         env.CICO_API_KEY = env.DUFFY_KEY

+         duffy_rtn=sh(

+             script: 'cico --debug node get -f value -c hostname -c comment',

+             returnStdout: true

+             ).trim().tokenize(' ')

+         env.DUFFY_NODE=duffy_rtn[0]

+         env.SSID=duffy_rtn[1]

+         env.BRANCH=params.BRANCH

+         env.REPO=params.REPO

+     }

  

-         stage('Allocate Node'){

-             env.CICO_API_KEY = env.DUFFY_KEY

-             duffy_rtn=sh(

-                 script: 'cico --debug node get -f value -c hostname -c comment',

-                 returnStdout: true

-                 ).trim().tokenize(' ')

-             env.DUFFY_NODE=duffy_rtn[0]

-             env.SSID=duffy_rtn[1]

-             env.BRANCH=params.BRANCH

-             env.REPO=params.REPO

+     try {

+         stage('Pre Setup Node'){

+             // Install EPEL

+             onmyduffynode 'yum -y install epel-release git'

          }

  

-         try {

-             stage('Pre Setup Node'){

-                 // Install EPEL

-                 onmyduffynode 'yum -y install epel-release git'

-             }

- 

-             stage('Notify PR'){

-                 notifyPagurePR("pagure", "Tests running ", "BUILDING", "STARTED")

-             }

+         stage('Notify PR'){

+             notifyPagurePR("pagure", "Tests running ", "BUILDING", "STARTED")

+         }

  

-             stage('Clone Test Suite') {

-                 onmyduffynode "GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone --single-branch --depth 1 https://pagure.io/pagure.git"

-             }

+         stage('Clone Test Suite') {

+             onmyduffynode "GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone --single-branch --depth 1 https://pagure.io/pagure.git"

+         }

  

-             stage('Run Test Suite') {

-                 timeout(time: 6, unit: 'HOURS') {

-                     onmyduffynode 'cd pagure && sh ./run_ci_tests_containers.sh'

-                 }

+         stage('Run Test Suite') {

+             timeout(time: 6, unit: 'HOURS') {

+                 onmyduffynode 'cd pagure && sh ./run_ci_tests_containers.sh'

              }

+         }

  

-         } catch (e) {

-             currentBuild.result = "FAILURE"

-             throw e

-         } finally {

- 

-             stage('Deallocate Node'){

-                 sh 'cico node done ${SSID}'

-             }

+     } catch (e) {

+         currentBuild.result = "FAILURE"

+         throw e

+     } finally {

  

-             stage('Notify PR'){

-                 res = currentBuild.currentResult

-                 notifyPagurePR("pagure", "Build " + res + "! ", res, "FINALIZED")

-             }

+         stage('Deallocate Node'){

+             sh 'cico node done ${SSID}'

+         }

  

+         stage('Notify PR'){

+             res = currentBuild.currentResult

+             notifyPagurePR("pagure", "Build " + res + "! ", res, "FINALIZED")

          }

+ 

      }

- }

+ } 

\ No newline at end of file

Agent can't be used in scripted pipeline, which is used by pagure project. This
means that the label needs to be defined differently as well.

For more info about scripted and declarative Jenkins pipeline see
https://www.jenkins.io/doc/book/pipeline/#declarative-versus-scripted-pipeline-syntax

Signed-off-by: Michal Konečný mkonecny@redhat.com

Pull-Request has been merged by pingou

2 years ago

Someday, I'd appreciate it if someone could explain how this pipeline works...

Metadata