}
def archive_logs(stackName) {
- sh "docker service ls |grep \"${stackname}\"| awk '{print \$2}'| xargs -iy docker service logs y --timestamps > containers_logs.txt 2>&1"
- archiveArtifacts artifacts: 'containers_logs.txt'
+ sh "docker service ls |grep \"${stackName}\"| awk '{print \$2}' | xargs -iy docker ps -af name=y --format \"{{.ID}} {{.Names}}\" --no-trunc | awk '{ print \"sudo cp /var/lib/docker/containers/\"\$1\"/\"\$1\"-json.log \"\$2\".log\"}' | xargs -iy bash -c y"
+ sh "sudo chown jenkins: osm*.log"
+ archiveArtifacts artifacts: '*.log'
}
node("${params.NODE}") {
{
repo_base_url = "-u ${params.REPOSITORY_BASE}"
}
- if ( params.DO_STAGE_4 ) {
- try {
+ if ( params.DO_STAGE_4 ) {
+ try {
sh "docker stack list |grep \"${container_name_prefix}\"| awk '{ print \$1 }'| xargs docker stack rm"
- }
- catch (caughtError) {
- println("Caught error: docker stack rm failed!")
- }
- }
+ }
+ catch (caughtError) {
+ println("Caught error: docker stack rm failed!")
+ }
+ }
sh """
export PATH=$PATH:/snap/bin
installers/full_install_osm.sh -y -s ${container_name} --test --nolxd --nodocker --nojuju --nohostports --nohostclient \
if ( ! currentBuild.result.equals('UNSTABLE') ) {
stage_archive = keep_artifacts
} else {
- error = new Exception("Smoke test failed")
- currentBuild.result = 'FAILURE'
- }
+ error = new Exception("Smoke test failed")
+ currentBuild.result = 'FAILURE'
+ }
}
}
stage_archive = keep_artifacts
} else {
println ("Systest test failed, throwing error")
- error = new Exception("Systest test failed")
- currentBuild.result = 'FAILURE'
- throw error
- }
+ error = new Exception("Systest test failed")
+ currentBuild.result = 'FAILURE'
+ throw error
+ }
}
}
stage("Docker Push") {
sh "make -C docker push INPUT_TAG=${container_name} TAG=${params.DOCKER_TAG}"
}
+
+ stage("Snap promotion") {
+ def snaps = ["osmclient"]
+ for (snap in snaps) {
+ channel=""
+ if (BRANCH_NAME.startsWith("v")) {
+ channel=BRANCH_NAME.substring(1)+"/"
+ } else if (BRANCH_NAME!="master") {
+ channel+="/"+BRANCH_NAME.replaceAll('/','-')
+ }
+ 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()
+ 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()
+
+ 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\"")
+ }
+ }
+ }
}
}
}
if (error) {
if ( !params.SAVE_CONTAINER_ON_FAIL ) {
uninstall_osm container_name
- sh "docker stop ${http_server_name}"
- sh "docker rm ${http_server_name}"
+ sh "docker stop ${http_server_name} || true"
+ sh "docker rm ${http_server_name} || true"
}
}
else {
if ( !params.SAVE_CONTAINER_ON_PASS ) {
uninstall_osm container_name
- sh "docker stop ${http_server_name}"
- sh "docker rm ${http_server_name}"
+ sh "docker stop ${http_server_name} || true"
+ sh "docker rm ${http_server_name} || true"
}
}
}