~thedac/mojo/unprivileged-containers

« back to all changes in this revision

Viewing changes to contrib/jenkins/job-templates/run.xml

add debian/ packaging, "make deb" target

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    <hudson.model.ParametersDefinitionProperty>
8
8
      <parameterDefinitions>
9
9
        <hudson.model.StringParameterDefinition>
10
 
          <name>MOJO_STAGE</name>
 
10
          <name>MOJO_ENV_TAG</name>
11
11
          <description>An environment tag, i.e. "staging" or "production."</description>
12
12
          <defaultValue>devel</defaultValue>
13
13
        </hudson.model.StringParameterDefinition>
14
 
        <hudson.model.ChoiceParameterDefinition>
 
14
        <org.jenkinsci.plugins.jobgenerator.parameters.GeneratorChoiceParameterDefinition plugin="jobgenerator@1.18">
15
15
          <name>MOJO_SERIES</name>
16
16
          <description>Distro series for this build.
17
17
                  Note that your juju-deployer stage files (from manifest's "deploy" lines) *must* have
23
23
              <string>trusty</string>
24
24
            </a>
25
25
          </choices>
26
 
        </hudson.model.ChoiceParameterDefinition>
27
 
        <hudson.model.ChoiceParameterDefinition>
 
26
        </org.jenkinsci.plugins.jobgenerator.parameters.GeneratorChoiceParameterDefinition>
 
27
        <org.jenkinsci.plugins.jobgenerator.parameters.GeneratorChoiceParameterDefinition plugin="jobgenerator@1.18">
28
28
          <name>RESET_JUJU_BEFORE</name>
29
29
          <description>Reset juju environment: destroy environment and re-bootstrap before test run.</description>
30
30
          <choices class="java.util.Arrays$ArrayList">
33
33
              <string>FALSE</string>
34
34
            </a>
35
35
          </choices>
36
 
        </hudson.model.ChoiceParameterDefinition>
37
 
        <hudson.model.ChoiceParameterDefinition>
 
36
        </org.jenkinsci.plugins.jobgenerator.parameters.GeneratorChoiceParameterDefinition>
 
37
        <org.jenkinsci.plugins.jobgenerator.parameters.GeneratorChoiceParameterDefinition plugin="jobgenerator@1.18">
38
38
          <name>RESET_JUJU_AFTER</name>
39
39
          <description>Destroy juju environment after test run.</description>
40
40
          <choices class="java.util.Arrays$ArrayList">
43
43
              <string>FALSE</string>
44
44
            </a>
45
45
          </choices>
46
 
        </hudson.model.ChoiceParameterDefinition>
47
 
        <hudson.model.StringParameterDefinition>
48
 
          <name>BUILD_TRIGGER</name>
49
 
          <description>what triggers this build: manual, daily, monitor, etc ...</description>
50
 
          <defaultValue>manual</defaultValue>
51
 
        </hudson.model.StringParameterDefinition>
 
46
        </org.jenkinsci.plugins.jobgenerator.parameters.GeneratorChoiceParameterDefinition>
52
47
      </parameterDefinitions>
53
48
    </hudson.model.ParametersDefinitionProperty>
54
49
  </properties>
100
95
exit_clean() {
101
96
    local status=$?
102
97
    info "Destroying juju environment (on exit, exit_status=$status) ..."
103
 
    juju destroy-environment -y -e ${JUJU_ENV?}
 
98
    juju destroy-environment -y
104
99
    exit $status
105
100
}
106
101
 
110
105
fi
111
106
# Enforce settings:
112
107
# - BZR_REVISION by Bazaar plugin,
113
 
# - MOJO_STAGE, MOJO_SERIES by mojo jenkins setup
114
 
: ${BZR_REVISION:?} ${MOJO_STAGE:?} ${MOJO_SERIES:?}
 
108
# - MOJO_ENV_TAG, MOJO_SERIES by mojo jenkins setup
 
109
: ${BZR_REVISION:?} ${MOJO_ENV_TAG:?} ${MOJO_SERIES:?}
115
110
export MOJO_PROJECT={{project_name}}
116
111
# JUJU_ENV needs to be different, depending on distro series
117
112
export JUJU_ENV=${MOJO_PROJECT}-${MOJO_SERIES}
121
116
set +e  # checks section: void exiting on failures
122
117
egrep -q "\b${JUJU_ENV}:" ~/.juju/environments.yaml
123
118
if [ $? -ne 0 ];then
124
 
    info "WARNING: JUJU_ENV=${JUJU_ENV} not found at ~/.juju/environments.yaml, expect FAILURE"
125
 
fi
 
119
    info "WARNING: JUJU_ENV=${JUJU_ENV} not found at ~/.juju/environments.yaml, expect failure"
 
120
fi
 
121
info "Checking for juju supported version ..."
 
122
JUJU_VER_OK="1.16."
 
123
if [ "$(expr match $(juju --version) ${JUJU_VER_OK})" -eq 0 ]; then
 
124
    error "Unsupported juju version $(juju --version), must be ${JUJU_VER_OK}x"
 
125
    exit 1
 
126
fi
 
127
info "Checking for mojo command ..."
126
128
MOJO_BIN=$(which mojo)
127
129
if [ $? -ne 0 ]; then
128
130
    error "'mojo' command not found in PATH=${PATH}"
142
144
fi
143
145
if [ "${RESET_JUJU_BEFORE,,}" != "false" ]; then
144
146
    info "Destroying juju environment ..."
145
 
    juju destroy-environment -y -e ${JUJU_ENV?}
 
147
    juju destroy-environment -y
146
148
    loop_until "juju status |&amp; egrep -i not.boot"
147
149
    info "Bootstraping juju environment ..."
148
 
    juju bootstrap --constraints "cpu-cores=1 mem=1G root-disk=50" --upload-tools --series ${MOJO_SERIES}
 
150
    juju bootstrap --constraints "cpu-cores=1 mem=1G root-disk=50" --upload-tools
149
151
    loop_until "juju status"
150
152
fi
151
153
 
154
156
# Use full binary path, for mojo via sudo:
155
157
sudo ${MOJO_BIN} project-new --series ${MOJO_SERIES} ${MOJO_PROJECT}
156
158
MOJO_LOCAL_DIR={{mojo_root}}/${MOJO_PROJECT}/LOCAL
157
 
MOJO_WORKSPACE=${BZR_REVISION}-${MOJO_STAGE}
 
159
MOJO_WORKSPACE=${BZR_REVISION}-${MOJO_ENV_TAG}
158
160
# Run mojo
159
 
cmd="mojo run --project ${MOJO_PROJECT} --series ${MOJO_SERIES} --stage ${MOJO_STAGE} ${SPEC_REPO} ${MOJO_WORKSPACE}"
 
161
cmd="mojo run --project ${MOJO_PROJECT} --series ${MOJO_SERIES} --stage ${MOJO_ENV_TAG} ${SPEC_REPO} ${MOJO_WORKSPACE}"
160
162
info "Running: $cmd"
161
163
bash -c "$cmd"
162
164
      </command>
164
166
  </builders>
165
167
  <buildWrappers>
166
168
      <org.jenkinsci.plugins.buildnamesetter.BuildNameSetter plugin="build-name-setter@1.3">
167
 
          <template>#${BUILD_NUMBER} series=${ENV,var="MOJO_SERIES"} stage=${ENV,var="MOJO_STAGE"} t=${ENV,var="BUILD_TRIGGER"}</template>
 
169
          <template>#${BUILD_NUMBER} series=${ENV,var="MOJO_SERIES"}</template>
168
170
      </org.jenkinsci.plugins.buildnamesetter.BuildNameSetter>
169
171
  </buildWrappers>
170
172
</project>