~sinzui/juju-ci-tools/cloudsigma-lib

« back to all changes in this revision

Viewing changes to manage-build-revision.bash

  • Committer: Nate Finch
  • Date: 2015-06-02 03:47:22 UTC
  • mfrom: (968 origin/trunk)
  • mto: This revision was merged to the branch mainline in revision 976.
  • Revision ID: nate.finch@canonical.com-20150602034722-cr3lzq2yb6xdh7gz
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
set -eu
 
3
 
 
4
if [[ -z ${JENKINS_USER:-} || -z ${JENKINS_PASSWORD:-} ]]; then
 
5
    echo "JENKINS_USER and JENKINS_PASSWORD must be defined."
 
6
    exit 1
 
7
fi
 
8
ACTION=$1
 
9
if [[ ! $ACTION =~ ^(enable|disable)$ ]]; then
 
10
    echo "Expected $0 <enable|disable>."
 
11
    exit 1
 
12
fi
 
13
HOURS=${2:-1}
 
14
 
 
15
 
 
16
CREDS="$JENKINS_USER:$JENKINS_PASSWORD"
 
17
JOB="http://$CREDS@juju-ci.vapour.ws:8080/job/build-revision"
 
18
 
 
19
 
 
20
# Empty the "C" queue. There can be only 1 or 0 jobs in it.
 
21
for job in $(atq -q c | cut  -f 1); do
 
22
    atrm $job
 
23
done
 
24
 
 
25
if [[ $ACTION == 'enable' ]]; then
 
26
    curl --data enable "$JOB/enable"
 
27
else
 
28
    curl --data disable "$JOB/disable"
 
29
    echo "Build-revision will be enabled in $HOURS hour"
 
30
    echo curl --data enable "$JOB/enable" | at -q c now +$HOURS hours
 
31
fi