背景
最近在调研devops这一块,看看业内的主流公司都是如何做一块的,看gitlab的ci/cd功能支持的挺完善,还支持pipeline,决定上手试一下。
Hello world
申请仓库
申请一个仓库hello world,在仓库中创建三个文件,分别为main.go,hello.go和hello_test.go。
- main.go
package main
import "fmt"
func main() {
str := hello()
fmt.Println(str)
}
- hello.go
package main
func hello() string {
return "hello"
}
- hello_test.go
package main
import (
"testing"
)
func TestHello(t *testing.T) {
want := "hello"
if get := hello(); get != want {
t.Fatalf("want:%s get:%s", want, get)
}
}
创建.gitlab-ci.yml文件
官方给了一个go语言的template参考着改一下
# This file is a template, and might need ed