harness-drone/.drone.jsonnet

114 lines
3.2 KiB
Text
Raw Normal View History

2019-02-19 23:56:41 +00:00
# defines the target version of Go. Please do not
# update this variable unless it has been previously
# approved on the mailing list.
local golang = "golang:1.11";
# defines a temporary volume so that the Go cache can
2019-04-16 01:27:15 +00:00
# be shared with all pipeline steps.
2019-02-19 23:56:41 +00:00
local volumes = [
{
name: "gopath",
temp: {},
},
];
# defines the default Go cache location as a volume
# that is mounted into pipeline steps.
local mounts = [
{
name: "gopath",
path: "/go",
},
];
# defines a pipeline step that builds and publishes
# a docker image to a docker remote registry.
2019-02-20 18:34:26 +00:00
local docker(name, image, os, arch) = {
2019-02-19 23:56:41 +00:00
name: "publish_" + name,
image: "plugins/docker",
settings: {
2019-02-20 06:42:25 +00:00
repo: "drone/" + if name == "server" then "drone" else name,
2019-02-19 23:56:41 +00:00
auto_tag: true,
auto_tag_suffix: os + "-" + arch,
username: { from_secret: "docker_username" },
password: { from_secret: "docker_password" },
dockerfile: "docker/Dockerfile." + name + "." + os + "." + arch,
},
when: {
event: [ "push", "tag" ],
},
};
# defines a pipeline step that creates and publishes
# a docker manifest to a docker remote registry.
local manifest(name) = {
name: name,
2019-03-06 00:48:28 +00:00
image: "plugins/manifest",
2019-02-19 23:56:41 +00:00
settings: {
2019-02-20 18:34:26 +00:00
auto_tag: true,
2019-02-19 23:56:41 +00:00
ignore_missing: true,
spec: "docker/manifest." + name + ".tmpl",
username: { from_secret: "docker_username" },
password: { from_secret: "docker_password" },
},
when: {
event: [ "push", "tag" ],
},
};
# defines a pipeline that builds, tests and publishes
# docker images for the Drone agent, server and controller.
local pipeline(name, os, arch) = {
kind: "pipeline",
name: name,
volumes: volumes,
platform: {
os: os,
arch: arch,
},
steps: [
{
name: "test",
image: golang,
volumes: mounts,
commands: [ "go test -v ./..." ],
},
{
name: "build",
image: golang,
volumes: mounts,
commands: [
2019-02-20 00:35:31 +00:00
"go build -ldflags \"-extldflags \\\\\"-static\\\\\"\" -o release/"+ os +"/" + arch + "/drone-server github.com/drone/drone/cmd/drone-server",
"CGO_ENABLED=0 go build -o release/"+ os +"/" + arch + "/drone-agent github.com/drone/drone/cmd/drone-agent",
"CGO_ENABLED=0 go build -o release/"+ os +"/" + arch + "/drone-controller github.com/drone/drone/cmd/drone-controller",
2019-02-19 23:56:41 +00:00
],
when: {
event: [ "push", "tag" ],
},
},
2019-02-20 18:34:26 +00:00
docker("agent", "agent", os, arch),
docker("controller", "controller", os, arch),
docker("server", "drone", os, arch),
2019-02-19 23:56:41 +00:00
],
};
[
pipeline("linux-amd64", "linux", "amd64"),
pipeline("linux-arm", "linux", "arm"),
pipeline("linux-arm64", "linux", "arm64"),
{
kind: "pipeline",
name: "manifest",
steps: [
2019-02-21 19:30:05 +00:00
manifest("server"),
2019-02-19 23:56:41 +00:00
manifest("controller"),
2019-03-06 00:49:58 +00:00
manifest("agent"),
2019-02-19 23:56:41 +00:00
],
depends_on: [
"linux-amd64",
"linux-arm",
"linux-arm64",
],
},
]