TT#100601 release_dashboard: support empty hotfix

Change-Id: Idad06fa1ad432483072c99294eb57769c4588bb9
pull/3/head
Victor Seva 6 years ago
parent fb763c917d
commit b802f1eb0a

@ -2,60 +2,64 @@
*
*
*/
$('button.hotfix').click(function(e){
$( "button.hotfix" ).click( function( e ) {
// don't send the form
e.preventDefault();
var button = $(this);
var id = button.attr('id').replace('hotfix_','');
var branch = $('select#version_' + id + ' option:selected').val().replace('branch/', '');
var button = $( this );
var id = button.attr( "id" ).replace( "hotfix_", "" );
var branch = $( "select#version_" + id + " option:selected" ).val().replace( "branch/", "" );
var repo = id;
var span = $('span#hotfix_error_' + id);
var push = $('select#push_' + id + ' option:selected').val();
var span = $( "span#hotfix_error_" + id );
var push = $( "select#push_" + id + " option:selected" ).val();
var empty = $( "input#empty_" + id ).prop( "checked" );
$.ajax({
url: branch + '/' + repo + '/',
type: 'POST',
data: JSON.stringify({push: push }),
$.ajax( {
url: branch + "/" + repo + "/",
type: "POST",
data: JSON.stringify( { push: push, empty: empty } ),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: successFunc,
error: errorFunc,
/* eslint-disable-next-line no-undef */ // at csrf.js
beforeSend: csrftokenFunc
});
} );
button.attr("disabled", "disabled");
span.html('processing');
button.attr( "disabled", "disabled" );
span.html( "processing" );
span.show();
function successFunc(data, status) {
span.html('');
span.append('<a href="' + data.url + '">Done</a>');
button.removeAttr("disabled");
function successFunc( data, _status ) {
span.html( "" );
span.append( "<a href=\"" + data.url + "\">Done</a>" );
button.removeAttr( "disabled" );
}
function errorFunc(jqXHR, status, error) {
span.html(error);
button.removeAttr("disabled");
function errorFunc( _jqXHR, _status, error ) {
span.html( error );
button.removeAttr( "disabled" );
}
});
} );
$('td.version > select').change(function() {
var id = $(this).attr('id').replace('version_','');
var version = $(this).val();
var button = $('button#hotfix_' + id);
var span = $('span#hotfix_error_' + id);
$( "td.version > select" ).change( function() {
var id = $( this ).attr( "id" ).replace( "version_", "" );
var version = $( this ).val();
var button = $( "button#hotfix_" + id );
var span = $( "span#hotfix_error_" + id );
if (version.match(/^branch\/mr[0-9]+\.[0-9]+\.[0-9]+$/)) {
button.html("Release hotfix");
button.removeAttr("disabled");
}
else {
button.html("Select branch to hotfix");
button.attr("disabled", "disabled");
if ( version.match( /^branch\/mr[0-9]+\.[0-9]+\.[0-9]+$/ ) ) {
button.html( "Release hotfix" );
button.removeAttr( "disabled" );
} else {
button.html( "Select branch to hotfix" );
button.attr( "disabled", "disabled" );
}
span.html('');
});
span.html( "" );
} );
$( document ).ready(function() {
$('td.version > select option[value^="branch/mr"]').each(function(){ $(this).change(); });
});
$( document ).ready( function() {
$( "td.version > select option[value^=\"branch/mr\"]" ).each( function() {
$( this ).change();
} );
} );

@ -13,6 +13,7 @@
<th>Project</th>
<th>Version</th>
<th>Push</th>
<th>Empty</th>
<th></th>
<th></th>
</tr>
@ -39,6 +40,9 @@
<option value="no">no</option>
</select>
</td>
<td>
<input id="empty_{{ p.name }}" type="checkbox">
</td>
<td>
<button type="button" id="hotfix_{{ p.name }}" class="btn btn-warning hotfix" disabled="disabled">Select branch to hotfix</button>
</td>
@ -53,6 +57,6 @@
</div>
{% endblock %}
{% block extrajs %}
<script src="{% static "release_dashboard/js/csrf.js" %}"></script>
<script src="{% static "release_dashboard/js/hotfix.js" %}"></script>
<script src="{% static 'release_dashboard/js/csrf.js' %}"></script>
<script src="{% static 'release_dashboard/js/hotfix.js' %}"></script>
{% endblock %}

@ -33,7 +33,8 @@ hotfix_url = (
"{base}/job/release-tools-runner/buildWithParameters?"
"token={token}&action={action}&branch={branch}&"
"PROJECTNAME={project}&repository={project}&"
"push={push}&uuid={uuid}&remote_user={user}"
"push={push}&release_empty_hotfix={empty}&"
"uuid={uuid}&remote_user={user}"
)
@ -45,8 +46,12 @@ def get_response(url):
return response
def trigger_hotfix(project, branch, user, push="yes"):
def trigger_hotfix(project, branch, user, push="yes", empty=False):
flow_uuid = uuid.uuid4()
if empty:
empty_val = "true"
else:
empty_val = "false"
params = {
"base": settings.JENKINS_URL,
"token": urllib.parse.quote(settings.JENKINS_TOKEN),
@ -54,6 +59,7 @@ def trigger_hotfix(project, branch, user, push="yes"):
"branch": urllib.parse.quote(branch),
"project": urllib.parse.quote(project),
"push": urllib.parse.quote(push),
"empty": empty_val,
"uuid": flow_uuid,
"user": user.username,
}

@ -1,4 +1,4 @@
# Copyright (C) 2015 The Sipwise Team - http://sipwise.com
# Copyright (C) 2015-2020 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@ -104,11 +104,11 @@ def hotfix_build(request, branch, project):
return HttpResponseNotFound(error)
json_data = json.loads(request.body.decode("utf-8"))
if json_data["push"] == "no":
push = json_data.get("push", "no")
empty = json_data.get("empty", False)
if push == "no":
logger.warn("dryrun for %s:%s", project, branch)
url = build.trigger_hotfix(
project, branch, request.user, json_data["push"]
)
url = build.trigger_hotfix(project, branch, request.user, push, empty)
return JsonResponse({"url": url})
@ -227,7 +227,10 @@ def build_trunk_deps_old(request):
else:
template = "release_dashboard/build_trunk_deps.html"
context = {
"projects": _projects_versions(trunk_build_deps, regex_master,),
"projects": _projects_versions(
trunk_build_deps,
regex_master,
),
"common_versions": {"tags": [], "branches": ["master"]},
"debian": settings.RELEASE_DASHBOARD_DEBIAN_RELEASES,
}
@ -245,7 +248,10 @@ def build_trunk_release_old(request):
return render(request, "release_dashboard/build_result.html", context)
else:
context = {
"projects": _projects_versions(trunk_projects, regex_master,),
"projects": _projects_versions(
trunk_projects,
regex_master,
),
"common_versions": {"tags": [], "branches": ["master"]},
"debian": settings.RELEASE_DASHBOARD_DEBIAN_RELEASES,
}

Loading…
Cancel
Save