gitlab_deploy.sh 2.22 KB
Newer Older
1
2
3
4
#!/bin/bash

#Get the line for the CVMFS status and chech if server is transaction
clicdp_status=`cvmfs_server list | grep clicdp`
5
if [[ $clicdp_status == *"(stratum0 / S3)"* ]]; then
6
  echo "No ongoing CVMFS transaction detected, initializing new transaction."
7
8
9
10
11
12
13
14
15
16
17
18
19
  # Start transaction
  cvmfs_server transaction clicdp.cern.ch

  # Deploy the latest Corryvreckan build
  echo "Deploying build: $2"
  if [[ $2 =~ v(.+?) ]]; then
    tag=${BASH_REMATCH[1]}
  else
    tag=$2
  fi
  cd /home/cvclicdp/

  # Extract artifact tars
20
  echo "Extracting artifact tarballs"
21
22
23
  for filename in $1/*.tar.gz; do
    echo " - $filename"

24
    if [[ $filename =~ corryvreckan-(.+?)-x ]]; then
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
      version=${BASH_REMATCH[1]}
      if [ "$version" != "$tag" ]; then
        echo "Build version does not match: $version"
        continue
      fi
    else
      echo "Unable to parse string $filename"
      continue
    fi

    if [[ $filename =~ $version-(.+?)\.tar ]]; then
      flavor=${BASH_REMATCH[1]}
      echo "Found build flavor:  $flavor"
    else
      echo "Unable to parse string $filename"
      continue
    fi

    # Create target directory and untar:
    mkdir -p /home/cvclicdp/release/$version/$flavor
    tar --strip-components=1 -xf $filename -C /home/cvclicdp/release/$version/$flavor/
  done

  # Check if we found any version and flavor to be installed:
  if [[ -z $version || -z $flavor ]]; then
    echo "Did not find suitable version or flavor to install."
51
    echo "Aborting CVMFS transaction."
Simon Spannagel's avatar
Simon Spannagel committed
52
    cvmfs_server abort -f clicdp.cern.ch
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    exit 1
  fi

  # Deleting old nightly build if it is not a tag
  if [ "$tag" == "latest" ]; then
    echo "Deleting old \"latest\" build"
    rm -rf /cvmfs/clicdp.cern.ch/software/corryvreckan/latest
  fi

  # Move new build into place
  echo "Moving new build into place"
  mv /home/cvclicdp/release/$tag /cvmfs/clicdp.cern.ch/software/corryvreckan/

  # Clean up old stuff
  rm -rf /home/cvclicdp/release

  # Publish changes
70
  echo "Publishing CVMFS transaction."
71
72
73
74
  cvmfs_server publish clicdp.cern.ch
  exit 0
else
  (>&2 echo "#################################")
75
76
  (>&2 echo "### CVMFS Transaction ongoing ###")
  (>&2 echo "####### Deploy cancelled  #######")
77
78
79
  (>&2 echo "#################################")
  exit 1
fi