广场合并另一个分支

时间:2018-11-19 19:38:41

标签: concourse concourse-git-resource

我正在尝试使用Concourse-CI自动化部署。

我有一个go应​​用程序,该应用程序已签入到具有两个分支(主控和开发)的本地Gitlab中。

我为运行分支测试的developer分支有一个管道设置,如果通过了,我想自动合并从developer分支到master分支的更改并用最新版本标记它。

这是我到目前为止所拥有的:

using CPQrp.Services;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.WsFederation;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SpaServices.AngularCli;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;

namespace CPQrp
{
public class Startup
{
    private IConfiguration _config;

    public Startup(IConfiguration configuration)
    {
        _config = configuration;
    }

    /// <summary>
    /// This method gets called by the runtime. Use this method to add services to the container.
    /// </summary>
    /// <param name="services"></param>
    public void ConfigureServices(IServiceCollection services)
    {
        // ROUTING
        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

        services.AddSpaStaticFiles(configuration =>
        {
            // In production, the Angular files will be served from this directory
            configuration.RootPath = "ClientApp/dist";
        });

        // CUSTOM SERVICES
        services.AddSingleton<IApplicationUser, ApplicationUser>();

        // AUTHENTICATION
        services.AddAuthentication(sharedOptions =>
        {
            sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            sharedOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            sharedOptions.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
        })
        .AddWsFederation(options =>
        {
            _config.Bind("ADFS", options);
        })
        .AddCookie(options =>
        {
            options.Cookie.Name = "auth";
            options.Cookie.Expiration = TimeSpan.FromDays(30);
        });
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="app"></param>
    /// <param name="env"></param>
    /// <param name="appUser"></param>
    /// <param name="logger"></param>
    public void Configure(IApplicationBuilder app,
                          IHostingEnvironment env,
                          IApplicationUser appUser,
                          ILogger<Startup> logger)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Error");
            app.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseAuthentication();
        app.Use(next =>
        {
            return async context =>
            {
                // DefaultAuthenticateScheme causes User to be set
                var user = context.User;

                // Not authenticated
                if (user == null || !user.Identities.Any(identity => identity.IsAuthenticated))
                {
                    await context.ChallengeAsync();
                }
                else
                {
                    if (!appUser.Exists())
                        appUser.LoadUserData(context);

                    await next(context);
                }
            };
        });
        app.UseStaticFiles();
        app.UseSpaStaticFiles();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller}/{action=Index}/{id?}");
        });

        app.UseSpa(spa =>
        {
            spa.Options.SourcePath = "ClientApp";

            if (env.IsDevelopment())
            {
                spa.UseAngularCliServer(npmScript: "start");
            }
        });
    }
}
}

问题在于,这只会用新版本标记master分支。

有没有办法将develop分支合并到master?

2 个答案:

答案 0 :(得分:4)

我想我一开始不了解文档,但是答案很简单。

- get: source-master
- get: source
- put: source-master
  params:
    repository: source

首先,在这种情况下,您必须同时拥有两个分支并进行开发。然后,您可以使用put将源本地存储库(concourse worker上的文件夹)推送到主存储库中。

不需要合并参数,而且我的存储库参数有误。

希望这对其他人有帮助。

答案 1 :(得分:0)

或者,您可以只使用脚本来处理更复杂的git命令。

 platform: linux

image_resource:
  type: docker-image
  source:
    repository: concourse/buildroot
    tag: git
    run:
      path: /bin/bash
      args:
      - -c
      - |
        set -eux

    git clone https://user:passw@devstack.vwgroup.com/bitbucket/scm/~user/kub-api-debug.git

    git config --global user.name "UserName"

    git config --global user.email "email@accenture.com"

    git checkout master

    git merge hotfix