Fix SCM macro usage of refspec, branches 56/3356/4
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Tue, 14 Apr 2020 13:55:55 +0000 (15:55 +0200)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Wed, 15 Apr 2020 11:59:12 +0000 (11:59 +0000)
- fix ignored refspec SCM parameter (hardcoded to empty string):
  s/refspec: ''/refspec: '$GERRIT_REFSPEC'/g
- fix IEC SCM configuration regression (broken in previous commit):
  s/branches: '$GERRIT_BRANCH'/branch: 'GERRIT_BRANCH'/g
- add missing lf-infra-parameters macro to bluval job;
- use lf-infra-gerrit-scm macro in IEC templates (now that submodule
  recursive cloning parametrization is supported);
- retire 'validation-job-parameters' parameters macro, which is only
  an alias for 'lf-infra-parameters';
- rework validation SCM handling for refs/tags/...;

JIRA: VAL-103

Change-Id: I94957fb02afdfe8a01330e768dc5fde15f5ea05d
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
jjb/akraino-templates/akraino-iec-templates.yaml
jjb/akraino-templates/akraino-jjb-docker.yaml
jjb/akraino-templates/akraino-jjb-templates.yaml
jjb/akraino-templates/akraino-validation-macros.yaml
jjb/akraino-templates/akraino-validation-templates.yaml
jjb/validation/validation-docker.yaml

index c60e915..8690514 100644 (file)
           name: '$BUILD_NUMBER - Scenario: $DEPLOY_SCENARIO $IEC_TYPE'
 
     scm: &scm
-      - git:
-          credentials-id: '{jenkins-ssh-credential}'
-          url: '{git-url}/{project}.git'
+      - lf-infra-gerrit-scm:
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          git-url: '{git-url}/{project}.git'
           refspec: '$GERRIT_REFSPEC'
-          branches: '$GERRIT_BRANCH'
-          skip-tag: true
-          wipe-workspace: true
-          submodule:
-            disable: true
-            recursive: false
-            timeout: '{submodule-timeout}'
+          branch: '$GERRIT_BRANCH'
+          submodule-recursive: false
+          submodule-timeout: '{submodule-timeout}'
+          submodule-disable: true
           choosing-strategy: default
 
     builders:
index 340659a..597b0fb 100644 (file)
@@ -31,8 +31,8 @@
       - lf-infra-gerrit-scm:
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
           git-url: '{git-url}/{project}.git'
-          refspec: ''
-          branch: '{branch}'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
           submodule-recursive: '{submodule-recursive}'
           submodule-timeout: '{submodule-timeout}'
           submodule-disable: false
@@ -74,8 +74,8 @@
       - lf-infra-gerrit-scm:
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
           git-url: '{git-url}/{project}.git'
-          refspec: ''
-          branch: '{branch}'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
           submodule-recursive: '{submodule-recursive}'
           submodule-timeout: '{submodule-timeout}'
           submodule-disable: false
index 82d34dd..52d4901 100644 (file)
       - lf-infra-gerrit-scm:
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
           git-url: '{git-url}/{project}.git'
-          refspec: ''
-          branch: '{branch}'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
           submodule-recursive: true
           submodule-timeout: '{submodule-timeout}'
           submodule-disable: false
index c484efd..471d2b9 100644 (file)
@@ -1,35 +1,7 @@
 ---
-#######
-# SCM #
-#######
-- scm:
-    # Enhanced version of the global-jjb
-    name: validation-infra-gerrit-scm
-    scm:
-      - git:
-          credentials-id: '{jenkins-ssh-credential}'
-          url: '{git-url}'
-          refspec: '{refspec}'
-          branches:
-            - 'refs/{refs_tag}/{stream}'
-          skip-tag: false
-          wipe-workspace: true
-          submodule:
-            recursive: '{submodule-recursive}'
-            timeout: '{submodule-timeout}'
-          choosing-strategy: '{choosing-strategy}'
-
 ##############
 # PARAMETERS #
 ##############
-- parameter:
-    name: validation-job-parameters
-    parameters:
-      - lf-infra-parameters:
-          project: '{project}'
-          stream: '{stream}'
-          branch: '{branch}'
-
 - parameter:
     name: bluval-defaults
     parameters:
 # settings for jobs run in multijob phases
 - docker-build-job-settings: &docker-build-job-settings
     name: docker_build_job_settings
-    current-parameters: false
-    git-revision: true
+    current-parameters: true
+    git-revision: false
     node-parameters: false
-    predefined-parameters: |
-      GERRIT_REFNAME=$GERRIT_REFNAME
     kill-phase-on: FAILURE
     abort-all-jobs: false
index d2a57f1..8a64fed 100644 (file)
@@ -8,7 +8,7 @@
     build-timeout: 90
 
     parameters:
-      - validation-job-parameters:
+      - lf-infra-parameters: &validation_lf_infra_parameters
           project: '{project}'
           branch: '{branch}'
           stream: '{stream}'
           blocking-jobs:
             - 'validation-docker-.*'
           block-level: 'NODE'
-    scm:
-      - validation-infra-gerrit-scm:
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-          git-url: '{git-url}/{project}.git'
-          refspec: ''
-          refs_tag: '{refs_tag}'
-          stream: '{stream}'
-          submodule-recursive: false
-          submodule-timeout: '{submodule-timeout}'
-          submodule-disable: false
-          choosing-strategy: default
 
     triggers:
       # Build nigtly at 12:10 AM
     build-timeout: 75
 
     parameters:
-      - validation-job-parameters:
-          project: '{project}'
-          branch: '{branch}'
-          stream: '{stream}'
-          arch_tag: '{arch_tag}'
+      - lf-infra-parameters: *validation_lf_infra_parameters
 
     properties:
       - build-blocker:
           blocking-jobs:
             - 'validation-docker-build-.*'
           block-level: 'NODE'
-    scm:
-     - validation-infra-gerrit-scm:
+    scm: &validation_scm
+      # lf-infra-gerrit-scm hardcodes branch specifier to refs/heads; while
+      # lf-infra-github-scm does not, allowing us to pass a fully custom '{branch}'
+      - lf-infra-github-scm:
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
-          git-url: '{git-url}/{project}.git'
-          refspec: ''
-          refs_tag: '{refs_tag}'
-          stream: '{stream}'
+          url: '{git-url}/{project}.git'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$STREAM'
           submodule-recursive: false
           submodule-timeout: '{submodule-timeout}'
           submodule-disable: false
       - lf-infra-docker-login:
           global-settings-file: global-settings
           settings-file: '{mvn-settings}'
-      - conditional-step:
-          condition-kind: regex-match
-          regex: '^tags$'
-          label: '{refs_tag}'
-          steps:
-            - shell: |
-                #!/bin/bash -ex
-                echo "export TAG_VER=$STREAM"  >> tag_version.sh
       - shell: |
           #!/bin/bash -ex
-          if [ -f tag_version.sh ]; then source tag_version.sh; fi
+          if [ "{branch}" != "{stream}" ]; then export TAG_VER=$STREAM; fi
           make -k -C docker push-all
-          rm -f tag_version.sh
-      - shell: |
-          #!/bin/bash -ex
           docker system prune -af
 
 - job-template:
     build-timeout: 15
 
     parameters:
-      - validation-job-parameters:
-          project: '{project}'
-          branch: '{branch}'
-          stream: '{stream}'
+      - lf-infra-parameters: *validation_lf_infra_parameters
 
     disabled: '{obj:disabled}'
 
-    scm:
-     - validation-infra-gerrit-scm:
-          jenkins-ssh-credential: '{jenkins-ssh-credential}'
-          git-url: '{git-url}/{project}.git'
-          refspec: ''
-          refs_tag: '{refs_tag}'
-          stream: '{stream}'
-          submodule-recursive: false
-          submodule-timeout: '{submodule-timeout}'
-          submodule-disable: false
-          choosing-strategy: default
+    scm: *validation_scm
 
     builders:
       - lf-infra-docker-login:
           global-settings-file: global-settings
           settings-file: '{mvn-settings}'
-      - conditional-step:
-          condition-kind: regex-match
-          regex: '^tags$'
-          label: '{refs_tag}'
-          steps:
-            - shell: |
-                #!/bin/bash -ex
-                echo "export TAG_VER=$STREAM"  >> tag_version.sh
       - shell: |
           #!/bin/bash -ex
-          if [ -f tag_version.sh ]; then source tag_version.sh; fi
+          if [ "{branch}" != "{stream}" ]; then export TAG_VER=$STREAM; fi
           for sd in docker/*/.; do make -k -C $sd .push_manifest; done
-          rm -f tag_version.sh
 
 - job-template:
     id: akraino-validation-lab-daily
     concurrent: true
     node: '{build-node}'
     parameters:
+      - lf-infra-parameters: *validation_lf_infra_parameters
       - string:
           name: DEPLOY_SCENARIO
           default: ''
       - {'bluval-defaults'}
 
     scm:
-      - git:
-          credentials-id: '{jenkins-ssh-credential}'
-          url: '{git-url}/validation.git'
-          refspec: ''
-          branches:
-            - 'refs/heads/{branch}'
-          skip-tag: true
-          wipe-workspace: true
-          submodule:
-            disable: true
-            recursive: false
-            timeout: '{submodule-timeout}'
+      - lf-infra-github-scm:
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          url: '{git-url}/{project}.git'
+          refspec: '$GERRIT_REFSPEC'
+          branch: '$GERRIT_BRANCH'
+          submodule-recursive: false
+          submodule-timeout: '{submodule-timeout}'
+          submodule-disable: true
           choosing-strategy: default
 
     builders:
index 0143422..37ff4ed 100644 (file)
@@ -6,11 +6,9 @@
     stream:
       - master:
           branch: '{stream}'
-          refs_tag: 'heads'
           disabled: false
       - 2.0.1:
           branch: 'master'
-          refs_tag: 'tags'
           disabled: true
 
     arch_tag: