Merge ~morphis/snappy-hwe-snaps/+git/jenkins-jobs:f/cleanup-workspace into ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master

Proposed by Simon Fels
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 02e50b7834b8614b3c8fe1451976726920716bb3
Merged at revision: 1d1d4bad01b19838298ee618027e8a054f4e40d8
Proposed branch: ~morphis/snappy-hwe-snaps/+git/jenkins-jobs:f/cleanup-workspace
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/jenkins-jobs:master
Diff against target: 55 lines (+20/-5)
2 files modified
jobs/image/common-job-prepare.sh (+10/-1)
jobs/snap/common-job-prepare.sh (+10/-4)
Reviewer Review Type Date Requested Status
Alfonso Sanchez-Beato Approve
System Enablement Bot continuous-integration Approve
Konrad Zapałowicz (community) code Approve
Review via email: mp+329420@code.launchpad.net

Description of the change

This will ensure that each build will start with an empty workspace. The script takes care that we don't erase the cloned jenkins-jobs repository.

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

ack

review: Approve (code)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Some issues, see below.

review: Needs Fixing
Revision history for this message
Simon Fels (morphis) wrote :

Fixed.

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/jobs/image/common-job-prepare.sh b/jobs/image/common-job-prepare.sh
2index 25c4950..6d5779e 100644
3--- a/jobs/image/common-job-prepare.sh
4+++ b/jobs/image/common-job-prepare.sh
5@@ -1,4 +1,4 @@
6-#!/bin/sh
7+#!/bin/sh -ex
8 #
9 # Copyright (C) 2017 Canonical Ltd
10 #
11@@ -25,6 +25,15 @@
12 #
13 # This file will be sourced by all jobs.
14
15+# Ensure we have a clean and empty workspace but keep our jenkins-jobs
16+# repository so we don't have to clone it again
17+for f in $(ls "${{WORKSPACE}}"); do
18+ if [ "${{f}}" = jenkins-jobs ]; then
19+ continue
20+ fi
21+ rm -rf "${{WORKSPACE}}"/"${{f}}"
22+done
23+
24 cat << EOF > $WORKSPACE/.build_env
25 BOT_USERNAME={bot_username}
26 LAUNCHPAD_PROJECT={launchpad_project}
27diff --git a/jobs/snap/common-job-prepare.sh b/jobs/snap/common-job-prepare.sh
28index 805a0ca..8c622ae 100644
29--- a/jobs/snap/common-job-prepare.sh
30+++ b/jobs/snap/common-job-prepare.sh
31@@ -1,4 +1,4 @@
32-#!/bin/sh
33+#!/bin/sh -ex
34 #
35 # Copyright (C) 2017 Canonical Ltd
36 #
37@@ -28,9 +28,15 @@
38 JENKINS_JOBS_GIT_REPO="{jobs-git-repo}"
39 JENKINS_JOBS_GIT_REPO_BRANCH="{jobs-git-repo-branch}"
40
41-if [ -n "${{CLEANUP_WORKSPACE}}" ] && [ "${{CLEANUP_WORKSPACE}}" -eq 1 ]; then
42- rm -rf ${{WORKSPACE}}/*
43-fi
44+# Ensure we have a clean and empty workspace but keep our jenkins-jobs
45+# repository so we don't have to clone it again
46+for f in $(ls "${{WORKSPACE}}"); do
47+ if [ "${{f}}" = jenkins-jobs ]; then
48+ continue
49+ fi
50+ rm -rf "${{WORKSPACE}}"/"${{f}}"
51+done
52+
53 if [ -e jenkins-jobs ] ; then
54 (cd jenkins-jobs ; git clean -fdx . ; git fetch origin ; git reset --hard origin/${{JENKINS_JOBS_GIT_REPO_BRANCH}})
55 else

Subscribers

People subscribed via source and target branches

to all changes: