首页 \ 问答 \ 如何缓存构建之间的Maven仓库?(How to cache maven repository between builds?)

如何缓存构建之间的Maven仓库?(How to cache maven repository between builds?)

我的目标是能够使用councourse构建管道构建,打包和测试使用maven构建的java项目。

这样的设置已经到位,并且一切运行良好,但由于我们的联系的恶劣Maven下载速度,生成时间太长。

我的构建作业yml文件使用以下资源作为maven构建的基础:

# ...
image_resource:
  type: docker-image
  source:
    repository: maven
    tag: '3.3-jdk-8'
# ...

我意识到这样一个事实,即对每一个建筑来说都有一个“空白的板岩”,这在建筑设计中是很重要的。

现在我的问题是:什么是缓存本地Maven仓库的好方法(比如,至少有一些像Spring这样的基本内容以及它的依赖关系)?

以下选项出现在我的脑海里:

  1. 使用已经内置依赖项的docker镜像
  2. 创建一个为我提供所需依赖项的资源

就我所见,选项1)不会使构建的下载大小更小,因为中心似乎不缓存用作构建作业基础的泊坞窗图像(或者我错了吗?)

在我继续之前,我想确保下面的选项2)给了我任何优势 - 中央缓存泊坞窗图像用作资源吗?

我可能会错过一些事情,因为我对议会比较陌生。 所以请原谅我,如果我强迫你在这里陈述明显的话。 :)


My goal is to be able to build, package and test a java project that is built with maven using a councourse build pipeline.

The setup as such is in place, and everything runs fine, but build times are much too long due to poor maven download rates from our nexus.

My build job yml file uses the following resource as base for the maven build:

# ...
image_resource:
  type: docker-image
  source:
    repository: maven
    tag: '3.3-jdk-8'
# ...

I am aware of the fact that having a "blank slate" for every buils is somwhat built into concourse by design.

Now my question is: what would be a good way to cache a local maven repository (say, with at least some basic stuff inside like Spring and it's dependencies)?

Following options come to my mind:

  1. Using a docker image that has the dependencies built-in already
  2. Creating a ressource that provides me the needed dependencies

As far as I can see, option 1) will not make the download size for the build smaller, as concourse seems to not cache docker images used as base for the build jobs (or am I wrong here?)

Before I move on, I would like to make sure that following option 2) gives me any advantage - does concourse cache docker images used as ressources?

I might miss out something, as I am relatively new to councourse. So forgive me if I force you to state the obvious here. :)


原文:https://stackoverflow.com/questions/40736296
更新时间:2023-05-16 17:05

最满意答案

只需检查参数是否present?

def create
  if params[:article_id].present?
    @article = Article.find(params[:article_id])
    @comment = @article.comments.create(comment_params)
    redirect_to article_path(@article)

  elsif params[:post_id].present?
    @post = Post.find(params[:post_id])
    @comment = @post.comments.create(comment_params)
    redirect_to post_path(@post)

  else
    # no parameter at all, redirect or render error page?
  end
end

Just check if the parameter is present?:

def create
  if params[:article_id].present?
    @article = Article.find(params[:article_id])
    @comment = @article.comments.create(comment_params)
    redirect_to article_path(@article)

  elsif params[:post_id].present?
    @post = Post.find(params[:post_id])
    @comment = @post.comments.create(comment_params)
    redirect_to post_path(@post)

  else
    # no parameter at all, redirect or render error page?
  end
end

相关问答

更多
  • 检查文档 ,友好的ID停止黑客find方法(为更大的好处),你现在必须做的: # Change Category.find to Category.friendly.find in your controller Category.friendly.find(params[:id]) Check the doc, friendly id stopped hacking find method (for the greater good), you now have to do: # Change Cate ...
  • 只需检查参数是否present? : def create if params[:article_id].present? @article = Article.find(params[:article_id]) @comment = @article.comments.create(comment_params) redirect_to article_path(@article) elsif params[:post_id].present? @post = P ...
  • 您没有将id传递给form_tag助手: <% @add_ons.each do |add_on| %> # some code here <%= form_tag('/stripe_checkout',{method: :post}) do %> <%= hidden_field_tag :id, add_on.id %>