coding上的免费的编译、打包、推镜像工具(cicd)太强了,必须分享一下

这篇博客介绍了如何使用Coding平台的持续集成功能为个人开源项目进行CI/CD。通过关联GitHub代码仓库,创建制品仓库和构建计划,结合Jenkinsfile定义流程,实现了从代码检出、编译到打包推镜像的自动化过程。Coding的CI/CD功能强大且易于使用,对于个人项目来说,其免费的300分钟构建时间也足够使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在做一些自己感兴趣的开源项目时,常常也会遇到需要进行持续集成的场景

如将一个项目进行编译、打包、推镜像

如果是在公司,一般会用公司的jenkins来进行持续集成

如果是个人项目,又没有jenkins等资源或者嫌麻烦,我尝试过用以下办法来解决:

  1. 如果是maven项目,可以使用fabric8docker-maven-plugin打包插件来进行,实现半自动化的方式进行打包和推镜像
  2. 如果是Github的项目,可以使用其中的Actions功能实现CICD,不过可能会遇到连国内镜像仓库网络不顺畅的问题,或高级功能需要付费

actions

一直在想有没有更好的方式实现CICD,正好今天就看到了coding上的持续集成功能,尝试了一下感觉非常好用,分享一下。

coding

主要流程

coding上的这个cicd功能比较多,devops的那一套感觉基本都实现完了,也有关于项目管理的一些功能,感觉着实很强。感兴趣的可以仔细研究一下,其官网地址为:https://coding.net/

使用起来个人感觉也是比较简单的,以一个github上的开源项目进行编码、打包、推镜像为例,主要步骤大致有以下:

1. 创建项目

顾名思义,就是创建一个项目
createProject

2. 关联代码仓库

项目创建好了之后,进入到项目中。

将这个项目对应的项目代码关联一下,支持多种仓库地址,如我这里的,将github上的代码关联一下
linkgit

3. 创建制品仓库

在【制品管理】中,创建一个制品。也就是产出物是什么,可以是docker、maven的jar包、helm啥的

productResult

如我这里的应用产出物是一个docker

4. 创建持续集成配置文件

在【持续集成】中选择构建计划,再点创建构建计划。

这个步骤也是最关键的地方,也就是jenkinsfile的定义。由它来进行项目的CICD的过程定义。

创建时可以选择某个模板来创建,改一改基本就可以用了。

cicdDef

也可以自己在文本编辑器中输入jenkinsfile的方式来创建。如我这里的:

pipeline {
  agent any
  environment {
    CODING_DOCKER_REG_HOST = "${CCI_CURRENT_TEAM}-docker.pkg.${CCI_CURRENT_DOMAIN}"
    CODING_DOCKER_IMAGE_NAME = "${PROJECT_NAME.toLowerCase()}/${DOCKER_REPO_NAME}/${DOCKER_IMAGE_NAME}"

  }
  stages {
    stage("检出") {
      steps {
        checkout(
          [$class: 'GitSCM',
          branches: [[name: GIT_BUILD_REF]],
          userRemoteConfigs: [[
            url: GIT_REPO_URL,
              credentialsId: CREDENTIALS_ID
            ]]]
        )
      }
    }
        

    stage('编译') {
      
      steps {
        sh "mvn clean package -Dmaven.test.skip=true -pl ${DOCKER_IMAGE_NAME} -am"
      }
    }
    
    stage('构建镜像并推送到 CODING Docker 制品库') {
      steps {
       script {
          env.cusversionall=sh(returnStdout: true, script: 'date +%Y%m%d%H%M').trim()
          echo "${cusversionall}"
          }

        sh "docker build -t ${CODING_DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}-${cusversionall} -f ${DOCKERFILE_PATH} ${DOCKER_BUILD_CONTEXT}"
        useCustomStepPlugin(
          key: 'SYSTEM:artifact_docker_push',
          version: 'latest',
          params: [
            image:"${CODING_DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}-${cusversionall}",
            repo:"${DOCKER_REPO_NAME}"
          ]
        )
      }
    }

  }
}

创建好了之后,点构建,输入启动参数就可以了。和jenkins上还是比较像的。

其中这上面的jenkinsfile我也是用模板里的改的,主要是将打包语句修改了一下,让其只打maven聚合工程中的某一个工程以搞高打包速度:

      steps {
        sh "mvn clean package -Dmaven.test.skip=true -pl ${DOCKER_IMAGE_NAME} -am"
      }

以及docker镜像以分支+时间戳的方式进行命名

       script {
          env.cusversionall=sh(returnStdout: true, script: 'date +%Y%m%d%H%M').trim()
          echo "${cusversionall}"
          }

doCicd

构建过程也还算是比较快的。

构建好了之后,在制品仓库中就可以看到对应的产出制品了。

dockerResult

最后再提一点的就是,由于这个是免费的,也有一定的资源限制,如构建分钟数每个月只有300分钟,不过对于个人的开源项目来讲感觉也足够了。

limit

类似UltraISO的系统镜像制作U盘启动工具。 Installing an operating system from a USB drive is much more convenient than from a disc, and a bootable drive even enables you to work from a system that does not have an OS installed. Rufus is a small-sized app that enables users to format USB flash disks and create bootable drives rapidly. It provides standard and advanced options alike, to suit the preferences of all skill levels. Format to the desired file system The tool is wrapped in a user-friendly interface that resembles the Format panel found in Windows built-in features. You can select a device, partition scheme and target system type, file system type (FAT32, NTFS, UDF, exFAT), cluster size, and new volume label. Connected devices are detected and selected from a drop-down menu. Be sure to save all important data, because the USB drive is formatted and everything is removed in the process. Compatibility options for old BIOS Basic formatting options enable you to check the device for bad blocks and select the algorithm type (from 1 to 4 passes). Plus, you can set the quick format mode, create an extended label and icon files, as well as create a bootable disk using an ISO or various other disc image types. Advanced tweaks can make Rufus list fixed (non-flash) or unpartitioned USB flash disks, add fixes for old BIOS (e.g. extra partition), and you may use Rufus MBR with a selected BIOS ID. To conclude The program records all activity to a separate panel, and it can be saved to a LOG file. It carries out a formatting task rapidly and error-free, using low system resources. We have not come across any issues during our tests since the utility did not cause Windows to hang or crash. To sum it up, Rufus is a straightforward solution to formatting and creating bootable USB drive, providing users with a series of useful features.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

水中加点糖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值