Advertisement
Guest User

Untitled

a guest
Aug 11th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 2.02 KB | None | 0 0
  1. # generates the .drone.yml file
  2. #   jsonnet -S .drone.jsonnet > .drone.jsonnet.yml
  3.  
  4. # return the golang image name for the provided
  5. # os and architecture.
  6. local golang(os, arch) =
  7.   if arch == 'arm' then
  8.     'arm32v7/golang:1.10.3'
  9.   else if arch == 'arm64' then
  10.     'arm64v8/golang:1.10.3'
  11.   else if os == 'windows' then
  12.     'golang:1.10.3-windowsservercore-1803'
  13.   else
  14.     'golang:1.10.3';
  15.  
  16. # return the docker plugin image name for the provided
  17. # os and architecture.
  18. local docker(os, arch) =
  19.   if arch == 'arm' then
  20.     'plugins/docker:linux-arm'
  21.   else if arch == 'arm64' then
  22.     'plugins/docker:linux-arm64'
  23.   else
  24.     'plugins/docker:latest';
  25.  
  26. # return the pipeline configuration for the provided
  27. # os and architecture.
  28. local pipeline(os, arch) = {
  29.   metadata: {
  30.     name: os + "-" + arch,
  31.   },
  32.   platform: {
  33.     name: os + "/" + arch,
  34.   },
  35.   pipeline: [
  36.     {
  37.       test: {
  38.         image: golang(os, arch),
  39.         commands: [
  40.           "cd posix",
  41.           "tar -xf fixtures.tar -C /",
  42.           "go test -v"
  43.         ]
  44.       }
  45.     },
  46.     {
  47.       publish: {
  48.         image: docker(os, arch),
  49.         repo: "drone/git",
  50.         dockerfile: "docker/Dockerfile." + os + "." + arch,
  51.         auto_tag: true,
  52.         auto_tag_suffix: os + "-" +arch,
  53.         secrets: [
  54.           "docker_username",
  55.           "docker_password"
  56.         ],
  57.         when: {
  58.           "event": [
  59.             "push",
  60.             "tag"
  61.           ]
  62.         }
  63.       }
  64.     }
  65.   ],
  66.   # secrets sources from the external AWS secrets
  67.   # manager using a secret plugin.
  68.   secrets: {
  69.     docker_username: {
  70.       external: {
  71.         name: "drone/docker#username"
  72.       }
  73.     },
  74.     docker_password: {
  75.       external: {
  76.         name: "drone/docker#password"
  77.       }
  78.     }
  79.   }
  80. };
  81.  
  82. # combine all architectures to create a multi-pipeline
  83. # build for multiple os and architecture combinations.
  84. std.manifestYamlStream([
  85.   pipeline("linux", "amd64"),
  86.   pipeline("linux", "arm"),
  87.   pipeline("linux", "arm64"),
  88. ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement