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

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

@ -33,7 +33,8 @@ hotfix_url = (
"{base}/job/release-tools-runner/buildWithParameters?" "{base}/job/release-tools-runner/buildWithParameters?"
"token={token}&action={action}&branch={branch}&" "token={token}&action={action}&branch={branch}&"
"PROJECTNAME={project}&repository={project}&" "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 return response
def trigger_hotfix(project, branch, user, push="yes"): def trigger_hotfix(project, branch, user, push="yes", empty=False):
flow_uuid = uuid.uuid4() flow_uuid = uuid.uuid4()
if empty:
empty_val = "true"
else:
empty_val = "false"
params = { params = {
"base": settings.JENKINS_URL, "base": settings.JENKINS_URL,
"token": urllib.parse.quote(settings.JENKINS_TOKEN), "token": urllib.parse.quote(settings.JENKINS_TOKEN),
@ -54,6 +59,7 @@ def trigger_hotfix(project, branch, user, push="yes"):
"branch": urllib.parse.quote(branch), "branch": urllib.parse.quote(branch),
"project": urllib.parse.quote(project), "project": urllib.parse.quote(project),
"push": urllib.parse.quote(push), "push": urllib.parse.quote(push),
"empty": empty_val,
"uuid": flow_uuid, "uuid": flow_uuid,
"user": user.username, "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 # 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 # 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) return HttpResponseNotFound(error)
json_data = json.loads(request.body.decode("utf-8")) 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) logger.warn("dryrun for %s:%s", project, branch)
url = build.trigger_hotfix( url = build.trigger_hotfix(project, branch, request.user, push, empty)
project, branch, request.user, json_data["push"]
)
return JsonResponse({"url": url}) return JsonResponse({"url": url})
@ -227,7 +227,10 @@ def build_trunk_deps_old(request):
else: else:
template = "release_dashboard/build_trunk_deps.html" template = "release_dashboard/build_trunk_deps.html"
context = { context = {
"projects": _projects_versions(trunk_build_deps, regex_master,), "projects": _projects_versions(
trunk_build_deps,
regex_master,
),
"common_versions": {"tags": [], "branches": ["master"]}, "common_versions": {"tags": [], "branches": ["master"]},
"debian": settings.RELEASE_DASHBOARD_DEBIAN_RELEASES, "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) return render(request, "release_dashboard/build_result.html", context)
else: else:
context = { context = {
"projects": _projects_versions(trunk_projects, regex_master,), "projects": _projects_versions(
trunk_projects,
regex_master,
),
"common_versions": {"tags": [], "branches": ["master"]}, "common_versions": {"tags": [], "branches": ["master"]},
"debian": settings.RELEASE_DASHBOARD_DEBIAN_RELEASES, "debian": settings.RELEASE_DASHBOARD_DEBIAN_RELEASES,
} }

Loading…
Cancel
Save