Modify KNI jobs to use ci in our internal repo 94/1294/2
authorYolanda Robla <yroblamo@redhat.com>
Wed, 31 Jul 2019 08:38:48 +0000 (10:38 +0200)
committerYolanda Robla <yroblamo@redhat.com>
Wed, 31 Jul 2019 18:58:36 +0000 (20:58 +0200)
The deploy scripts need to be moved to the internal repo,
in order to be reused. Also, as deploy is part of the logic
of the process and not part of the CI itself, moving them to
the internal project seems more reasonable.

Signed-off-by: Yolanda Robla <yroblamo@redhat.com>
Change-Id: Iab289664dfc48186805a168575076c74c9dd8b7d

jjb/akraino-templates/akraino-jjb-kni.yaml
jjb/akraino-templates/akraino-jjb-macros.yaml [new file with mode: 0644]
jjb/shell/kni_deploy_aws.sh [deleted file]
jjb/shell/kni_deploy_libvirt.sh [deleted file]

index 16f0db5..f031301 100644 (file)
           comment-contains-value: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(recheck|reverify)$'
 
     scm:
-      - lf-infra-gerrit-scm:
+      - akraino-lf-infra-gerrit-scm:
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
           git-url: '{git-url}/{project}.git'
           refspec: '$GERRIT_REFSPEC'
           submodule-timeout: '{submodule-timeout}'
           submodule-disable: false
           choosing-strategy: default
-
+          basedir: 'blueprint-pae'
+      - akraino-lf-infra-gerrit-scm:
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          git-url: '{git-url}/kni/installer.git'
+          refspec: 'refs/heads/master'
+          branch: 'master'
+          submodule-recursive: '{submodule-recursive}'
+          submodule-timeout: '{submodule-timeout}'
+          submodule-disable: false
+          choosing-strategy: default
+          basedir: 'installer'
     triggers:
       - gerrit:
           server-name: '{gerrit-server-name}'
               target: akraino-secrets/coreos-pull-secret
       - shell: !include-raw-escape:
           - ../shell/install_go.sh
-      - shell: !include-raw-escape:
-          - ../shell/kni_deploy_aws.sh
+      - shell: ./installer/ci/kni_deploy_aws.sh
 
     publishers:
       - lf-infra-publish
               file-paths: '{obj:gerrit_trigger_file_paths}'
 
     scm:
-      - lf-infra-gerrit-scm:
+      - akraino-lf-infra-gerrit-scm:
           jenkins-ssh-credential: '{jenkins-ssh-credential}'
           git-url: '{git-url}/{project}.git'
           refspec: '$GERRIT_REFSPEC'
           submodule-timeout: '{submodule-timeout}'
           submodule-disable: false
           choosing-strategy: default
-
+          basedir: 'blueprint-pae'
+      - akraino-lf-infra-gerrit-scm:
+          jenkins-ssh-credential: '{jenkins-ssh-credential}'
+          git-url: '{git-url}/kni/installer.git'
+          refspec: 'refs/heads/master'
+          branch: 'master'
+          submodule-recursive: '{submodule-recursive}'
+          submodule-timeout: '{submodule-timeout}'
+          submodule-disable: false
+          choosing-strategy: default
+          basedir: 'installer'
     builders:
       - lf-infra-pre-build
       - config-file-provider:
               target: akraino-secrets/ssh-pub-key
       - shell: !include-raw-escape:
           - ../shell/install_go.sh
-      - shell: !include-raw-escape:
-          - ../shell/kni_deploy_libvirt.sh
+      - shell: ./installer/ci/kni_deploy_libvirt.sh
 
     publishers:
       - lf-infra-publish
diff --git a/jjb/akraino-templates/akraino-jjb-macros.yaml b/jjb/akraino-templates/akraino-jjb-macros.yaml
new file mode 100644 (file)
index 0000000..639e632
--- /dev/null
@@ -0,0 +1,17 @@
+- scm:
+    # enhanced version of the global-jjb, based on ta-common-macros
+    name: akraino-lf-infra-gerrit-scm
+    scm:
+      - git:
+          credentials-id: '{jenkins-ssh-credential}'
+          url: '{git-url}'
+          refspec: '{refspec}'
+          branches:
+            - 'refs/heads/{branch}'
+          skip-tag: true
+          wipe-workspace: true
+          submodule:
+            recursive: '{submodule-recursive}'
+            timeout: '{submodule-timeout}'
+          choosing-strategy: '{choosing-strategy}'
+          basedir: '{basedir}'
diff --git a/jjb/shell/kni_deploy_aws.sh b/jjb/shell/kni_deploy_aws.sh
deleted file mode 100755 (executable)
index d9c468d..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2019 Red Hat
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#        http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -e -u -x -o pipefail
-
-export PATH=$PATH:/usr/local/go/bin:/usr/local/bin
-KNI_PATH='src/gerrit.akraino.org/kni/'
-SITE_NAME='edge-sites-testing.devcluster.openshift.com'
-
-echo '---> Starting kni installer generation'
-export GOPATH=${WORKSPACE}/
-
-# move the blueprint to an inner directory
-mkdir ${WORKSPACE}/blueprint-pae
-mv base profiles sites tools ${WORKSPACE}/blueprint-pae/
-
-# clone installer in the right directory
-sudo rm -rf ${WORKSPACE}/${KNI_PATH}
-mkdir -p ${WORKSPACE}/${KNI_PATH}
-pushd ${WORKSPACE}/${KNI_PATH}/
-git clone https://gerrit.akraino.org/r/kni/installer
-pushd installer
-
-# first build kni installer
-make build 2>&1 | tee ${WORKSPACE}/build.log
-
-# add the right credentials to kni
-mkdir $HOME/.kni || true
-cp $WORKSPACE/akraino-secrets/coreos-pull-secret $HOME/.kni/pull-secret.json || true
-
-# start the workflow
-./knictl fetch_requirements file://${WORKSPACE}/blueprint-pae//sites/${SITE_NAME} 2>&1 | tee ${WORKSPACE}/aws_requirements.log
-./knictl prepare_manifests ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/aws_manifests.log
-
-# now run the cluster
-source $HOME/.kni/${SITE_NAME}/profile.env
-$HOME/.kni/${SITE_NAME}/requirements/openshift-install create cluster --dir=/$HOME/.kni/${SITE_NAME}/final_manifests 2>&1 | tee ${WORKSPACE}/aws_deploy.log
-STATUS=$?
-
-# output tfstate
-echo "metadata.json for removing cluster"
-cat $HOME/.kni/${SITE_NAME}/final_manifests/metadata.json
-
-if [ $STATUS -ne 0 ]; then
-    echo "Error deploying in AWS"
-    exit 1
-fi
-
-echo "Cluster successfully deployed! Start applying workloads"
-./knictl apply_workloads ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/aws_workloads.go
-STATUS=$?
-
-if [ $STATUS -ne 0 ]; then
-    echo "Error applying workloads to AWS"
-    exit 1
-fi
-
-echo "Workloads successfully applied! Starting cleanup"
-$HOME/.kni/${SITE_NAME}/requirements/openshift-install destroy cluster --dir=/$HOME/.kni/${SITE_NAME}/final_manifests 2>&1 | tee ${WORKSPACE}/aws_destroy.log
-STATUS=$?
-
-popd
-
-exit $STATUS
diff --git a/jjb/shell/kni_deploy_libvirt.sh b/jjb/shell/kni_deploy_libvirt.sh
deleted file mode 100755 (executable)
index f5d1932..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2019 Red Hat
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#        http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -e -u -x -o pipefail
-
-export PATH=$PATH:/usr/local/go/bin:/usr/local/bin
-KNI_PATH='src/gerrit.akraino.org/kni/'
-SITE_NAME='testing.virt.edge-sites.net'
-
-echo '---> Starting kni installer generation'
-export GOPATH=${WORKSPACE}/
-
-function approve_certs() {
-    # sleep for the first 10 min
-    sleep 600
-
-    # temporary fix, autoapprove certificates on background
-    while /bin/true; do
-        export KUBECONFIG=$HOME/.kni/${SITE_NAME}/final_manifests/auth/kubeconfig
-        oc get csr | grep worker | grep Pending | awk '{print $1}' | xargs -n 1 oc adm certificate approve || true
-        sleep 60
-    done
-}
-
-# move the blueprint to an inner directory
-mkdir ${WORKSPACE}/blueprint-pae
-mv base profiles sites tools ${WORKSPACE}/blueprint-pae/
-
-# clone installer in the right directory
-sudo rm -rf ${WORKSPACE}/${KNI_PATH}
-mkdir -p ${WORKSPACE}/${KNI_PATH}
-pushd ${WORKSPACE}/${KNI_PATH}/
-git clone https://gerrit.akraino.org/r/kni/installer
-pushd installer
-
-# first build kni installer
-make build 2>&1 | tee ${WORKSPACE}/build.log
-
-# do a host preparation and cleanup
-bash utils/prep_host.sh virt.edge-sites.net
-wget https://raw.githubusercontent.com/openshift/installer/master/scripts/maintenance/virsh-cleanup.sh
-chmod a+x ./virsh-cleanup.sh
-sudo -E bash -c "yes Y | ./virsh-cleanup.sh"
-
-# add the right credentials to kni
-mkdir $HOME/.kni || true
-cp $WORKSPACE/akraino-secrets/coreos-pull-secret $HOME/.kni/pull-secret.json || true
-cp $HOME/.ssh/id_rsa.pub $HOME/.kni/id_rsa.pub || true
-
-# start the workflow
-sudo rm -rf /$HOME/.kni/${SITE_NAME}/final_manifests || true
-./knictl fetch_requirements file://${WORKSPACE}/blueprint-pae//sites/${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_requirements.log
-./knictl prepare_manifests ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_manifests.log
-
-# now run the cluster
-source $HOME/.kni/${SITE_NAME}/profile.env
-approve_certs &
-FUNCTION_PID=$!
-sudo -E $HOME/.kni/${SITE_NAME}/requirements/openshift-install create cluster --dir=/$HOME/.kni/${SITE_NAME}/final_manifests 2>&1 | tee ${WORKSPACE}/libvirt_deploy.log
-STATUS=$?
-kill $FUNCTION_PID || true
-
-# output tfstate
-echo "metadata.json for removing cluster"
-cat $HOME/.kni/${SITE_NAME}/final_manifests/metadata.json
-
-if [ $STATUS -ne 0 ]; then
-    echo "Error deploying in libvirt"
-    exit 1
-fi
-
-echo "Cluster successfully deployed! Start applying workloads"
-./knictl apply_workloads ${SITE_NAME} 2>&1 | tee ${WORKSPACE}/libvirt_workloads.log
-STATUS=$?
-
-if [ $STATUS -ne 0 ]; then
-    echo "Error applying workloads to libvirt"
-    exit 1
-fi
-
-popd
-popd
-
-exit $STATUS