Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker support for pipeline runs #201

Merged
merged 21 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docker/Dockerfile.golang
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.12.7-alpine3.8
FROM golang:1.12.7-alpine

# Version and other variables which can be changed.
ENV GAIA_PORT=8080 \
Expand All @@ -13,7 +13,7 @@ COPY gaia-linux-amd64 /app
# Fix permissions & setup known hosts file for ssh agent.
# Install git.
RUN chmod +x ./gaia-linux-amd64 \
&& apk add --no-cache --virtual git \
&& apk add --no-cache git \
&& mkdir -p /root/.ssh \
&& touch /root/.ssh/known_hosts \
&& chmod 600 /root/.ssh
Expand Down
1 change: 1 addition & 0 deletions frontend/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
ij_javascript_force_semicolon_style = false
4 changes: 2 additions & 2 deletions frontend/src/helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
for (let argsCurr = 0; argsCurr < pipeline.jobs[pipelineCurr].args.length; argsCurr++) {
if (pipeline.jobs[pipelineCurr].args[argsCurr].type !== 'vault') {
// we found args. Redirect user to params view.
context.$router.push({ path: '/pipeline/params', query: { pipelineid: pipeline.id } })
context.$router.push({ path: '/pipeline/params', query: { pipelineid: pipeline.id, docker: pipeline.docker } })
return
}
}
Expand All @@ -23,7 +23,7 @@ export default {
StartPipeline (context, pipeline) {
// Send start request
context.$http
.post('/api/v1/pipeline/' + pipeline.id + '/start')
.post('/api/v1/pipeline/' + pipeline.id + '/start', { docker: pipeline.docker })
.then(response => {
if (response.data) {
context.$router.push({ path: '/pipeline/detail', query: { pipelineid: pipeline.id, runid: response.data.id } })
Expand Down
25 changes: 24 additions & 1 deletion frontend/src/views/overview/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,22 @@
</span><br/>
<div class="pipelinegrid-footer">
<a class="button is-primary" @click="checkPipelineArgsAndStartPipeline(pipeline.p)"
style="width: 100%;">
style="width: 49%; margin-right: 10px;">
<span class="icon">
<i class="fa fa-play-circle"></i>
</span>
<span>Start Pipeline</span>
</a>
<toggle-button
id="pipelinedocker"
v-model="pipeline.p.docker"
:color="{checked: '#7DCE94', unchecked: '#82C7EB'}"
:labels="{checked: 'Docker enabled', unchecked: 'Docker disabled'}"
v-on:change="onDockerRunChange(pipeline.p)"
:width=140
:height=35
:font-size=12
:sync="true"/>
</div>
</div>
</div>
Expand All @@ -80,6 +90,7 @@
<script>
import moment from 'moment'
import helper from '../../helper'
import { ToggleButton } from 'vue-js-toggle-button'

export default {
data () {
Expand All @@ -102,6 +113,10 @@ export default {
this.$store.commit('appendInterval', intervalID)
},

components: {
ToggleButton
},

destroyed () {
this.$store.commit('clearIntervals')
},
Expand Down Expand Up @@ -148,6 +163,14 @@ export default {
helper.StartPipelineWithArgsCheck(this, pipeline)
},

onDockerRunChange (pipeline) {
this.$http
.put('/api/v1/pipeline/' + pipeline.id, pipeline)
.catch((error) => {
this.$onError(error)
})
},

getImagePath (type) {
return require('../../assets/images/' + type + '.png')
},
Expand Down
61 changes: 58 additions & 3 deletions frontend/src/views/pipeline/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@
</span>
<span>Add Pipeline Trigger</span>
</a>
<a class="button is-primary" v-on:click="showSetPipelineWorkerTags">
<a class="button is-primary" v-on:click="showSetPipelineWorkerTags" style="margin-right: 5px;">
<span class="icon">
<i class="fa fa-tags"></i>
</span>
<span>Set Pipeline Worker Tags</span>
</a>
<a class="button is-primary" v-on:click="showCustomOptionsModal">
<span class="icon">
<i class="fa fa-cogs"></i>
</span>
<span>Custom Options</span>
</a>
</p>
<span style="color: red" v-if="periodicSchedulesErr">Periodic schedules invalid: {{ periodicSchedulesErrMsg }}</span>
</div>
Expand Down Expand Up @@ -350,6 +356,42 @@
</div>
</modal>

<!-- pipeline custom options -->
<modal :visible="customOptionsModal" class="modal-z-index" @close="close">
<div class="box credentials-modal">
<div class="block credentials-modal-content">
<collapse accordion is-fullwidth>
<collapse-item title="Docker options:" selected>
<div class="credentials-modal-content">
<message :direction="'down'" style="padding-bottom: 10px;"
message="
If enabled, Gaia will automatically run this pipeline in a docker container
by default."
:duration="0">
</message>
<p class="control has-icons-left" style="padding-bottom: 5px;">
<toggle-button
v-model="createPipeline.pipeline.docker"
id="pipelinedocker"
:color="{checked: '#7DCE94', unchecked: '#82C7EB'}"
:labels="{checked: 'On', unchecked: 'Off'}"
:sync="true"/>
</p>
</div>
</collapse-item>
</collapse>
<div class="modal-footer">
<div style="float: left;">
<button class="button is-primary" v-on:click="customOptionsModalConfirm">Confirm</button>
</div>
<div style="float: right;">
<button class="button is-danger" v-on:click="cancel">Cancel</button>
</div>
</div>
</div>
</div>
</modal>

<!-- status output modal -->
<modal :visible="statusOutputModal" class="modal-z-index" @close="closeStatusModal">
<div class="box statusModal">
Expand Down Expand Up @@ -378,6 +420,7 @@ import moment from 'moment'
import Notification from 'vue-bulma-notification-fixed'
import Message from 'vue-bulma-message-html'
import VueTagsInput from '@johmun/vue-tags-input'
import { ToggleButton } from 'vue-js-toggle-button'

const NotificationComponent = Vue.extend(Notification)
const openNotification = (
Expand Down Expand Up @@ -466,7 +509,8 @@ export default {
statusOutputMsg: '',
setPipelineWorkerTagsModal: false,
selectedPipelineWorkerTags: [],
currentTag: ''
currentTag: '',
customOptionsModal: false
}
},

Expand All @@ -477,7 +521,8 @@ export default {
ProgressBar,
Message,
VueTagsInput,
VueGoodTable
VueGoodTable,
ToggleButton
},

mounted () {
Expand Down Expand Up @@ -649,6 +694,7 @@ export default {
this.gitWebHookModal = false
this.periodicalPipelineScheduleModal = false
this.setPipelineWorkerTagsModal = false
this.customOptionsModal = false
this.$emit('close')
},

Expand All @@ -661,6 +707,7 @@ export default {
this.createPipeline.pipeline.repo.privatekey.password = ''
this.periodicSchedules = ''
this.selectedPipelineWorkerTags = []
this.createPipeline.pipeline.docker = false

this.close()
},
Expand All @@ -673,6 +720,10 @@ export default {
this.gitWebHookModal = true
},

showCustomOptionsModal () {
this.customOptionsModal = true
},

showPeriodicalPipelineScheduleModal () {
this.periodicSchedules = ''
if (typeof this.createPipeline.pipeline.periodicschedules !== 'undefined') {
Expand Down Expand Up @@ -726,6 +777,10 @@ export default {
this.close()
},

customOptionsModalConfirm () {
this.close()
},

showSetPipelineWorkerTags () {
this.selectedPipelineWorkerTags = []
for (let i = 0; i < this.createPipeline.pipeline.tags.length; i++) {
Expand Down
28 changes: 14 additions & 14 deletions frontend/src/views/pipeline/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,19 @@ export default {
this.drawPipelineDetail(pipeline.data, pipelineRun.data)
}
this.runsRows = pipelineRuns.data
let tempLastSuccessfulRunId = -1;
let tempLastRunId = -1;
let tempLastSuccessfulRunId = -1
let tempLastRunId = -1
for (let runI = 0; runI < pipelineRuns.data.length; runI++) {
if (pipelineRuns.data[runI].status == 'success') {
if (pipelineRuns.data[runI].status === 'success') {
if (pipelineRuns.data[runI].id > tempLastSuccessfulRunId) {
this.lastSuccessfulRun = pipelineRuns.data[runI];
tempLastSuccessfulRunId = pipelineRuns.data[runI].id;
this.lastSuccessfulRun = pipelineRuns.data[runI]
tempLastSuccessfulRunId = pipelineRuns.data[runI].id
}
}

if (pipelineRuns.data[runI].id > tempLastRunId) {
this.lastRun = pipelineRuns.data[runI];
tempLastRunId = pipelineRuns.data[runI].id;
this.lastRun = pipelineRuns.data[runI]
tempLastRunId = pipelineRuns.data[runI].id
}
}
this.pipeline = pipeline.data
Expand All @@ -297,19 +297,19 @@ export default {
// Are runs available?
if (pipelineRuns.data) {
this.runsRows = pipelineRuns.data
let tempLastSuccessfulRunId = -1;
let tempLastRunId = -1;
let tempLastSuccessfulRunId = -1
let tempLastRunId = -1
for (let runI = 0; runI < pipelineRuns.data.length; runI++) {
if (pipelineRuns.data[runI].status == 'success') {
if (pipelineRuns.data[runI].status === 'success') {
if (pipelineRuns.data[runI].id > tempLastSuccessfulRunId) {
this.lastSuccessfulRun = pipelineRuns.data[runI];
tempLastSuccessfulRunId = pipelineRuns.data[runI].id;
this.lastSuccessfulRun = pipelineRuns.data[runI]
tempLastSuccessfulRunId = pipelineRuns.data[runI].id
}
}

if (pipelineRuns.data[runI].id > tempLastRunId) {
this.lastRun = pipelineRuns.data[runI];
tempLastRunId = pipelineRuns.data[runI].id;
this.lastRun = pipelineRuns.data[runI]
tempLastRunId = pipelineRuns.data[runI].id
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions frontend/src/views/pipeline/params.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</p>
<p class="control" v-else-if="arg.type === 'boolean'">
<label class="checkbox">
<input type="checkbox">
<input type="checkbox" v-model="arg.value">
{{ arg.desc }}
</label>
</p>
Expand All @@ -35,7 +35,8 @@ export default {
data () {
return {
args: [],
pipelineID: null
pipelineID: null,
docker: false
}
},

Expand All @@ -56,12 +57,17 @@ export default {
return
}
this.pipelineID = pipelineID
this.docker = this.$route.query.docker

// reset args
this.args = []

this.$http
.get('/api/v1/pipeline/' + pipelineID, { showProgressBar: false })
.get('/api/v1/pipeline/' + pipelineID, {
params: {
hideProgressBar: true
}
})
.then(response => {
if (response.data) {
let pipeline = response.data
Expand All @@ -88,6 +94,9 @@ export default {
},

startPipeline () {
// Add docker option
this.args.push({ docker: this.docker })

// Send start request
this.$http
.post('/api/v1/pipeline/' + this.pipelineID + '/start', this.args)
Expand Down
Loading