X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=jenkins%2Fci-pipelines%2Fci_stage_3.groovy;h=ee50a3f08ad9928108fed746070918eaad9814a6;hb=1d704d9e31c8a002f38afbbc33929d13baaa8e45;hp=449d1b682636e5ba957da331a510874a4f7b986c;hpb=c828a582cacde3e65ed2eb4da97c3821584686b2;p=osm%2Fdevops.git diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 449d1b68..ee50a3f0 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -32,7 +32,7 @@ properties([ string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'), string(defaultValue: 'osm-stage_4', description: '', name: 'DOWNSTREAM_STAGE_NAME'), string(defaultValue: 'testing-daily', description: '', name: 'DOCKER_TAG'), - booleanParam(defaultValue: true, description: '', name: 'SAVE_CONTAINER_ON_FAIL'), + booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'), booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'), booleanParam(defaultValue: true, description: '', name: 'SAVE_ARTIFACTS_ON_SMOKE_SUCCESS'), booleanParam(defaultValue: true, description: '', name: 'DO_STAGE_4'), @@ -47,7 +47,7 @@ properties([ string(defaultValue: '/home/jenkins/hive/robot-systest.cfg', description: '', name: 'ROBOT_VIM'), string(defaultValue: '/home/jenkins/hive/kubeconfig.yaml', description: '', name: 'KUBECONFIG'), string(defaultValue: '/home/jenkins/hive/clouds.yaml', description: '', name: 'CLOUDS'), - string(defaultValue: 'Charmed', description: '', name: 'INSTALLER'), + string(defaultValue: 'Default', description: '', name: 'INSTALLER'), ]) ]) @@ -55,7 +55,7 @@ def uninstall_osm(stackName) { sh """ export OSM_USE_LOCAL_DEVOPS=true export PATH=$PATH:/snap/bin - installers/full_install_osm.sh -y -w /tmp/osm -t ${stackName} -s ${stackName} --test --nolxd --nodocker --nojuju --nohostports --nohostclient --uninstall + installers/full_install_osm.sh -y -c swarm -w /tmp/osm -t ${stackName} -s ${stackName} --test --nolxd --nodocker --nojuju --nohostports --nohostclient --uninstall """ } @@ -120,11 +120,22 @@ def archive_logs(remote) { for container in `kubectl get pods -n osm | grep -v operator | grep -v NAME| awk '{print $1}'`; do logfile=`echo $container | cut -d- -f1` echo "Extracting log for $logfile" - kubectl logs -n osm $container 2>&1 > logs/$logfile.log + kubectl logs -n osm $container --timestamps=true 2>&1 > logs/$logfile.log done ''' } else { - // collect logs from k8s based installer... + sshCommand remote: remote, command: ''' + for deployment in `kubectl -n osm get deployments | grep -v operator | grep -v NAME| awk '{print $1}'`; do + echo "Extracting log for $deployment" + kubectl -n osm logs deployments/$deployment --timestamps=true --all-containers 2>&1 > logs/$deployment.log + done + ''' + sshCommand remote: remote, command: ''' + for statefulset in `kubectl -n osm get statefulsets | grep -v operator | grep -v NAME| awk '{print $1}'`; do + echo "Extracting log for $statefulset" + kubectl -n osm logs statefulsets/$statefulset --timestamps=true --all-containers 2>&1 > logs/$statefulset.log + done + ''' } sh "rm -rf logs" @@ -148,6 +159,7 @@ def get_value(key, output) { node("${params.NODE}") { INTERNAL_DOCKER_REGISTRY = 'osm.etsi.org:5050/devops/cicd/' + INTERNAL_DOCKER_PROXY = 'http://172.21.1.1:5000' SSH_KEY = '~/hive/cicd_rsa' sh 'env' @@ -296,9 +308,10 @@ node("${params.NODE}") { println("Launching new VM") output=sh(returnStdout: true, script: """#!/bin/sh -e for line in `grep OS ~/hive/robot-systest.cfg | grep -v OS_CLOUD` ; do export \$line ; done - openstack server create --flavor m1.xlarge \ + openstack server create --flavor osm.sanity \ --image ubuntu18.04 \ --key-name CICD \ + --property build_url="${BUILD_URL}" \ --nic net-id=osm-ext \ ${container_name} """).trim() @@ -374,10 +387,12 @@ node("${params.NODE}") { remote.identityFile = SSH_KEY remote.allowAnyHosts = true remote.logLevel = 'INFO' + remote.pty = true sshCommand remote: remote, command: """ - wget https://osm-download.etsi.org/ftp/osm-8.0-eight/install_osm.sh + wget https://osm-download.etsi.org/ftp/osm-9.0-nine/install_osm.sh chmod +x ./install_osm.sh + sed -i '1 i\\export PATH=/snap/bin:\${PATH}' ~/.bashrc """ if ( useCharmedInstaller ) { @@ -388,7 +403,6 @@ node("${params.NODE}") { sudo sed -i "s|https://registry-1.docker.io|http://172.21.1.1:5000|" /var/snap/microk8s/current/args/containerd-template.toml sudo systemctl restart snap.microk8s.daemon-containerd.service sudo snap alias microk8s.kubectl kubectl - echo export PATH=/snap/bin:\${PATH} > ~/.bashrc ''' withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry', @@ -403,14 +417,26 @@ node("${params.NODE}") { --tag ${container_name} """ } - prometheusHostname = "prometheus."+IP_ADDRESS+".xip.io" + prometheusHostname = "prometheus."+IP_ADDRESS+".nip.io" prometheusPort = 80 - osmHostname = "nbi."+IP_ADDRESS+".xip.io:443" + osmHostname = "nbi."+IP_ADDRESS+".nip.io:443" } else { - // Run -k8s installer here - // Update to use 172.21.1.1 as the dockerhub proxy - // Specify registry to use for installer - // set osmHostname, prometheusHostname, prometheusPort as needed + // Run -k8s installer here specifying internal docker registry and docker proxy + withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry', + usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { + sshCommand remote: remote, command: """ + ./install_osm.sh -y \ + ${repo_base_url} \ + ${repo_key_name} \ + ${release} -r unstable \ + -d ${USERNAME}:${PASSWORD}@${INTERNAL_DOCKER_REGISTRY} \ + -p ${INTERNAL_DOCKER_PROXY} \ + -t ${container_name} + """ + } + prometheusHostname = IP_ADDRESS + prometheusPort = 9091 + osmHostname = IP_ADDRESS } } } @@ -418,11 +444,7 @@ node("${params.NODE}") { stage_archive = false if ( params.DO_SMOKE ) { stage("OSM Health") { - if ( useCharmedInstaller ) { - stackName = "osm" - } else { - stackName = container_name - } + stackName = "osm" sshCommand remote: remote, command: """ /usr/share/osm-devops/installers/osm_health.sh -k -s ${stackName} """ @@ -441,7 +463,7 @@ node("${params.NODE}") { hostfile="${tempdir}/hosts" sh """cat << EOF > ${hostfile} 127.0.0.1 localhost -${remote.host} prometheus.${remote.host}.xip.io nbi.${remote.host}.xip.io +${remote.host} prometheus.${remote.host}.nip.io nbi.${remote.host}.nip.io EOF""" } else { hostfile=null @@ -465,7 +487,7 @@ EOF""" } } } finally { - stage("Archive Contailer Logs") { + stage("Archive Container Logs") { // Archive logs to containers_logs.txt archive_logs(remote) if ( ! currentBuild.result.equals('UNSTABLE') && ! currentBuild.result.equals('FAILURE')) { @@ -497,8 +519,9 @@ EOF""" stage("Snap promotion") { def snaps = ["osmclient"] + sh "snapcraft login --with ~/.snapcraft/config" for (snap in snaps) { - channel="" + channel="latest/" if (BRANCH_NAME.startsWith("v")) { channel=BRANCH_NAME.substring(1)+"/" } else if (BRANCH_NAME!="master") { @@ -506,26 +529,19 @@ EOF""" } track=channel+"edge\\*" edge_rev=sh(returnStdout: true, - script: "sudo docker run -v ~/.snapcraft:/snapcraft -v ${WORKSPACE}:/build " + - "-w /build snapcore/snapcraft:stable /bin/bash -c " + - "\"snapcraft login --with /snapcraft/config &>/dev/null && " + - "snapcraft revisions $snap\" | " + - "grep \" $track\" | tail -1 | awk '{print \$1}'").trim() + script: "snapcraft revisions $snap | " + + "grep \"$track\" | tail -1 | awk '{print \$1}'").trim() + print "edge rev is $edge_rev" track=channel+"beta\\*" beta_rev=sh(returnStdout: true, - script: "sudo docker run -v ~/.snapcraft:/snapcraft -v ${WORKSPACE}:/build " + - "-w /build snapcore/snapcraft:stable /bin/bash -c " + - "\"snapcraft login --with /snapcraft/config &>/dev/null && " + - "snapcraft revisions $snap\" | " + - "grep \" $track\" | tail -1 | awk '{print \$1}'").trim() + script: "snapcraft revisions $snap | " + + "grep \"$track\" | tail -1 | awk '{print \$1}'").trim() + print "beta rev is $beta_rev" if ( edge_rev != beta_rev ) { print "Promoting $edge_rev to beta in place of $beta_rev" beta_track=channel+"beta" - sh("sudo docker run -v ~/.snapcraft:/snapcraft -v ${WORKSPACE}:/build " + - "-w /build snapcore/snapcraft:stable /bin/bash -c " + - "\"snapcraft login --with /snapcraft/config &>/dev/null && " + - "snapcraft release $snap $edge_rev $beta_track\"") + sh "snapcraft release $snap $edge_rev $beta_track" } } } @@ -565,4 +581,4 @@ EOF""" sh "docker rm ${http_server_name} || true" } } -} \ No newline at end of file +}