windows 下配置 gitlab-runner 及编译可执行程序

news/2025/3/4 20:28:06/文章来源:https://www.cnblogs.com/circlelll/p/18751339

linux 上安装 gitlab

安装方式:

  • Install on Linux
  • Install on Kubernetes
  • Install with Docker
  • Compile from source
  • Install from cloud provider

Install on Linux

GitLab下载安装_GitLab安装和配置_GitLab最新中文官网免费版下载-极狐GitLab

1. 安装和配置所需的依赖

sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl

注释:

配置电子邮件通知:见附

2. 下载并安装极狐GitLab

执行以下命令配置极狐GitLab 软件源镜像。

curl -L get.gitlab.cn | bash

指定域名安装,此处http,EXTERNAL_URL可不设置

sudo EXTERNAL_URL="http://gitlab.example.com" apt-get install -y gitlab-jh

报错:

GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your JiHu GitLab instance by setting external_url
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your JiHu GitLab instance by running the following command:
sudo gitlab-ctl reconfigure

解决:执行配置

gitlab-ctl reconfigure
gitlab-ctl restart

其他命令:

gitlab-ctl stop

注释:

配置https和其他:见附

3. 登录极狐GitLab 实例

使用第二步 EXTERNAL_URL 中配置的地址来访问安装成功的极狐GitLab 实例。用户名默认为 root 。如果在安装过程中指定了初始密码,则用初始密码登录,如果未指定密码,则系统会随机生成一个密码并存储在 /etc/gitlab/initial_root_password 文件中, 查看随机密码并使用 root 用户名登录。

注意:出于安全原因,24 小时后,/etc/gitlab/initial_root_password 会被第一次 gitlab-ctl reconfigure 自动删除,因此若使用随机密码登录,建议安装成功初始登录成功之后,立即修改初始密码。

信息:

http://localhost
http://ip
修改密码:123456

4. 后续配置

完成安装后,请参考建议的后续配置,包括身份验证选项和注册限制的配置。

windows 上安装 gitlab-runner

安装

Install GitLab Runner on Windows | GitLab Docs

1. 创建文件夹

E:\GitLab-Runner

2. 下载二进制程序

64-bit or 32-bit

放到E:\GitLab-Runner

改名为gitlab-runner.exe(可选)

3. 确保权限

E:\GitLab-Runner文件夹和exe程序确保限制写权限。如果不设置这些权限,普通用户可以替换可执行文件,并以提升的权限运行任意代码。

4. 运行命令行

Starting Windows PowerShell - PowerShell | Microsoft Learn

5. 注册一个 runner

# 注册命令
.\gitlab-runner.exe register
# 输入url
http://ip
# token
GR1348941GDbRfggTDey1yfCDayQw
# 配置文件
E:\\GitLab-Runner\\config.toml

或者,使用非交互模式

.\gitlab-runner.exe register \--non-interactive \--url "https://gitlab.com/" \--token "$RUNNER_TOKEN" \--executor "docker-windows" \--docker-image mcr.microsoft.com/windows/servercore:1809_amd64 \--description "docker-runner"

6. 安装 runner 为服务并启动

使用内置系统账号(推荐)或用户账号

内置系统账号

cd E:\GitLab-Runner
.\gitlab-runner.exe install
.\gitlab-runner.exe start

或用户账号

cd E:\GitLab-Runner
.\gitlab-runner.exe install --user ENTER-YOUR-USERNAME --password ENTER-YOUR-PASSWORD
.\gitlab-runner.exe start

7. 可选(并行配置)

参考: advanced configuration details

配置文件:E:\GitLab-Runner\config.toml

使用

在windows上编译 c 程序

使用 MinGW

是什么:

MinGW项目(官方网站)是Minimalist GNU for Windows的缩写,是本地Windows应用程序的极简主义开发环境,该项目旨在将gcc编译器移植到Windows系统上

安装:

最新!MinGW-w64的下载与安装(超详细!!!) - 知乎

示例:

hello.c

/* file hello.c */
#include <stdio.h>
#include <stdlib.h>int main(void)
{/* 打印Hello World */printf("Hello World.\n");/* 程序暂停,便于观察结果 */system("pause");/* 程序返回,结束 */return 0;
}

编译:

gcc hello.c
a.exe

安装make

在windows上安装make - 知乎

Makefile

hello.exe:hello.cgcc hello.c -o hello.exe

编译运行

make
hello.exe

使用 MSVC

  • MinGW-w64 是一个 Windows 平台的 GCC 编译器工具链,支持编译 Windows 应用程序。
  • Visual Studio 2019 通常使用 MSVC(Microsoft Visual C++)编译器,而 MinGW-w64 使用 GCC 编译器。

示例:还是需要安装 Visual Studio 2019

stages:- buildbuild_windows:stage: buildtags:- windows  # 使用 Windows 环境的 Runnerscript:- echo "Setting up MSVC environment..."- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64- echo "Building with MSVC..."- cl /EHsc /Fe:myprogram.exe myprogram.cartifacts:paths:- myprogram.exeexpire_in: 1 week  # 制品保存 1 周

在runner里集成

.gitlab-ci.yml

stages:          # List of stages for jobs, and their order of execution- buildbuild-job:       # This job runs in the build stage, which runs first.stage: buildtags:- lymscript:- echo "Compiling the code..."- gcc hello.c -o hello.exe#- hello.exe- cp hello.exe hello1.exe- echo "Compile complete."- echo "make the code..."- make#- hello.exe- echo "make complete."artifacts:paths:- hello1.exe- hello.exeexpire_in: 1 day  # 制品保存 1 周

报错一:

Running with gitlab-runner 17.9.0 (c4cbe9dd)

on lym t3_B1Nd5, system ID: s_b41fe35ab3ce

Preparing the "shell" executor00:00

Using Shell (pwsh) executor...

Preparing environment00:01

ERROR: Job failed (system failure): prepare environment: failed to start process: starting OS command: exec: "pwsh": executable file not found in %PATH%. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

解决:

修改配置文件:config.toml

executor = "shell"
shell = "pwsh" # 此行pwsh改为powershell

重启

.\gitlab-runner.exe stop
.\gitlab-runner.exe start

报错二:

Running with gitlab-runner 17.9.0 (c4cbe9dd)

on lym t3_B1Nd5, system ID: s_b41fe35ab3ce

Preparing the "shell" executor00:00

Using Shell (powershell) executor...

Preparing environment00:02

Running on NJZF--NFPPPONVV...

Getting source from Git repository00:05

Fetching changes with git depth set to 20...

Initialized empty Git repository in E:/GitLab-Runner/builds/t3_B1Nd5/0/circle/test/.git/

Created fresh repository.

fatal: unable to access 'http://gitlab.example.com/circle/test.git/': Could not resolve host: gitlab.example.com

Cleaning up project directory and file based variables00:00

ERROR: Job failed: exit status 128

现象:安装gitping 域名不通,ping ip能通

解决:runner机器上配置hosts中ip和域名的映射关系:windows(C:\Windows\System32\drivers\etc),linux(/etc/hosts)

ip gitlab.example.com

配置电子邮件通知

(可选)如果要使用 Postfix 来发送电子邮件通知,执行以下安装命令。

sudo apt-get install -y postfix

如果您想使用其他解决方案发送电子邮件,请跳过上面 Postfix 安装步骤并在安装极狐GitLab 后配置外部 SMTP 服务器。

配置https和其他

接下来,安装极狐GitLab。安装之前,需要确保您的DNS设置正确。此外,还需要通过设置 EXTERNAL_URL 环境变量来指定极狐GitLab 实例的 URL。

如果您想通过 HTTPS 来访问实例,那么您可以根据官方文档进行配置,让实例使用 Let's Encrypt 自动请求 SSL 证书,这需要有效的主机名和入站 HTTP 访问。您也可以使用自己的证书或仅使用 http://(不带 s)。

如果您想为初始管理员用户( root )指定自定义的初始密码,可以根据文档指导进行配置。否则将默认生成随机密码。

接下来执行如下命令开始安装:

sudo EXTERNAL_URL="https://gitlab.example.com" apt-get install -y gitlab-jh

其他配置详情可以查看 Omnibus 安装配置文档。

参考

GitLab Docs

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/893611.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

WEB攻防-机制验证篇重定向发送响应状态码跳过步骤验证码回传枚举

笔记: 验证码突破:回传的时候泄露了发送的验证码导致不需要知道目标的验证码是多少直接使用数据包里面的队列 规律爆破:就是常见的数字四位或者六位 10000 种可能在规定时间内爆破或者多次验证后网站不会出现新的验证码没有次数限制可以尝试爆破或者是汉字进行 重定向用户:通过…

Docker 安装 Redis 容器

1、下载Redis镜像下载指定版本的Redis镜像 (xxx指具体版本号) docker pull redis:xxx docker pull redis 下载最新版Redis镜像 (其实此命令就等同于 : docker pull redis:latest ),我用5.0.5版本。docker pull redis:5.0.52、 检查当前所有Docker下载的镜像docker images

Script-Server:用Web UI轻松管理你的脚本执行

# 监控 # 运维人员 在现代软件开发和运维中,脚本的使用频繁而广泛。然而,如何让非技术人员轻松、安全地运行这些脚本成为了一个挑战。 幸运的是,Script-Server应运而生,它是一个为脚本提供的Web用户界面,可以让用户通过一个直观的界面执行各种脚本,而无需编写代码。本文…

nuxtjs + scss + unocss + pinia 新建项目

1、通过命令行报错的,直接下载压缩包 pnpm dlx nuxi init <project-name>压缩包地址:https://codeload.github.com/nuxt/starter/tar.gz/refs/heads/v3 2、安装插件 1、安装unocss pnpm install --save-dev @unocss/nuxt unocss# nuxt.config.jsmodules: [@unocss/nuxt…

【Azure 环境】执行 az ad user show –id 报错 Insufficient privileges to complete the operation

执行 az ad user show –id 报错 Insufficient privileges to complete the operation问题描述 本地环境中,执行 az ad user show -id 时候,报错 insufficient privileges to complete the operation !问题解答 此报错说明,登录Azure (az login) 时,所使用的账号权限不足所…

VMware ESXi 8.0U3d macOS Unlocker OEM BIOS 2.7 集成网卡驱动和 NVMe 驱动 (集成驱动版)

VMware ESXi 8.0U3d macOS Unlocker & OEM BIOS 2.7 集成网卡驱动和 NVMe 驱动 (集成驱动版)VMware ESXi 8.0U3d macOS Unlocker & OEM BIOS 2.7 集成网卡驱动和 NVMe 驱动 (集成驱动版) 发布 ESXi 8.0U3 集成驱动版,在个人电脑上运行企业级工作负载 请访问原文链接:…

VMware Fusion 13.6.3 OEM BIOS 2.7 - 在 macOS 中运行 Windows 虚拟机的最佳方式

VMware Fusion 13.6.3 OEM BIOS 2.7 - 在 macOS 中运行 Windows 虚拟机的最佳方式VMware Fusion 13.6.3 OEM BIOS 2.7 - 在 macOS 中运行 Windows 虚拟机的最佳方式 VMware Fusion 13 原版 App 中集成 OEM BIOS 请访问原文链接:https://sysin.org/blog/vmware-fusion-13-oem/ …

VMware Workstation 17.6.3 发布下载,现在完全免费无论个人还是商业用途

VMware Workstation 17.6.3 发布下载,现在完全免费无论个人还是商业用途VMware Workstation 17.6.3 发布下载,现在完全免费无论个人还是商业用途 VMware Workstation 17.6.3 Pro for Windows & Linux - 领先的免费桌面虚拟化软件 基于 x86 的 Windows、Linux 桌面虚拟化软…

[51Nod 1558] 树中的配对

前言 这能不会, 这能不会, 这能不会??? 做了一会之后, 感觉确实可以不会 思路题意 带权树求一组排列 ppp 使得 dis(i,pi)→max⁡\textrm{dis} (i, p_i) \to \maxdis(i,pi​)→max结论 一条边最多的经过次数就是其连接的两部分中较小的那一个证明方法 \(1\) 调整法 首先点对初…

微信小程序快递代理新手必看:3种方法轻松上手

很多朋友都在问我,如何开始快递代理业务。其实,这个兼职工作门槛很低,只要你有空闲时间,就能开始赚钱。下面我给大家分享一下具体的操作方法。 首先可以让客服帮你搭建小程序,这样推广就可以自助让客户下单,是需要推广!以后客户用了就能一直下单获取持续收益了。 快递代…

2025.03.04 CW 模拟赛 A. 树

题面 A. 树 思路 先说结论, 每条边的贡献次数等于其左右两侧子树大小的最小值. 证明#include "iostream" #include "vector"using namespace std;typedef pair<int, int> pii; typedef long long ll;constexpr int N = 2e5 + 10;int n, sz[N]; ll an…

【python免杀】CS免杀+浅谈Python静态免杀

本文我们再来看看利用python进行静态免杀吧! 先用CS生成 shellcode 把shellcode进行加密放在里面并存放到服务器。 python BS64 shellcode.txt这里为了方便,我们直接放到了kali的apache目录下。 并启动Apache service apache2 start修改加载器的服务器地址后进行一次BS64加密…