Drone

Is it possible to use host network in v1?

In 0.8 I was able to set network_mode: “host”, is it possible in v1?
Jsonnet plugin drops it from the yaml output.

Yes, this was to Drone version 1.2.3 and the latest version of the CLI. You can test with the following commands:

$ cat .drone.jsonnet
[{
  kind: "pipeline",
  name: "default",
  steps: [
    {
      name: "test",
      image: "alpine:3.8",
      commands: [ "echo hello" ],
      network_mode: "host"
    },
  ]
}]

$ drone jsonnet --stdout --stream
---
kind: pipeline
name: default

platform:
  os: linux
  arch: amd64

steps:
- name: test
  image: alpine:3.8
  commands:
  - echo hello
  network_mode: host

...

Please note the drone-jsonnet-plugin has not been updated to reflect this change because the server now has an embedded jsonnet parser, which has superceded the jsonnet plugin. You can enabled the embedded jsonnet parser by setting DRONE_JSONNET_ENABLED=true

@bradrydzewski Thanks, but one more question about embedded jsonnet, every time I change build file to my .drone.jsonnet in the UI I get this error: “linter: invalid or missing image”

Here is my compose file:

image: drone/drone:1.2.3
ports:
  - 80:80
  - 443:443
volumes:
  - /var/run/docker.sock:/var/run/docker.sock
  - /var/lib/drone:/data
restart: always
environment:
  - DRONE_AGENTS_ENABLED=true
  - DRONE_JSONNET_ENABLED=true

this would imply the jsonnet file generates a yaml file that is invalid or is missing an image tag. I would need to see your exact jsonnet file to advise further.

It works if I run a jsonnet cli converter and use yaml result in drone.

local build(arch) = {
    kind: "pipeline",
    name: arch,

    platform: {
        os: "linux",
        arch: arch
    },
    steps: [
        {
            name: "version",
            image: "syncloud/build-deps-" + arch,
            commands: [
                "echo $(date +%y%m%d)$DRONE_BUILD_NUMBER > version",
                "echo gogs > name",
                "echo " + arch + "$DRONE_BRANCH > domain"
            ]
        },
        {
            name: "build",
            image: "syncloud/build-deps-" + arch,
            commands: [
                "NAME=$(cat name)",
                "VERSION=$(cat version)",
                "./build.sh $NAME $VERSION"
            ]
        },
        {
            name: "test-intergation",
            image: "syncloud/build-deps-" + arch,
            commands: [
              "pip2 install -r dev_requirements.txt",
              "APP_ARCHIVE_PATH=$(realpath $(cat package.name))",
              "DOMAIN=$(cat domain)",
              "NAME=$(cat name)",
              "cd integration",
              "py.test -x -s verify.py --domain=$DOMAIN --app-archive-path=$APP_ARCHIVE_PATH --device-host=device --app=$NAME --device-user=gogs"
            ]
        },
        if arch == "arm" then {} else
        {
            name: "test-ui",
            image: "syncloud/build-deps-" + arch,
            commands: [
              "pip2 install -r dev_requirements.txt",
              "DOMAIN=$(cat domain)",
              "NAME=$(cat name)",
              "cd integration",
              "xvfb-run -l --server-args='-screen 0, 1024x4096x24' py.test -x -s test-ui.py --ui-mode=desktop --domain=$DOMAIN --device-host=device --app=$NAME --device-user=gogs",
              "xvfb-run -l --server-args='-screen 0, 1024x4096x24' py.test -x -s test-ui.py --ui-mode=mobile --domain=$DOMAIN --device-host=device --app=$NAME --device-user=gogs",
            ],
            volumes: [{
                name: "shm",
                path: "/dev/shm"
            }]
        },
        {
            name: "upload",
            image: "syncloud/build-deps-" + arch,
            environment: {
                AWS_ACCESS_KEY_ID: {
                    from_secret: "AWS_ACCESS_KEY_ID"
                },
                AWS_SECRET_ACCESS_KEY: {
                    from_secret: "AWS_SECRET_ACCESS_KEY"
                }
            },
            commands: [
              "VERSION=$(cat version)",
              "NAME=$(cat name)",
              "PACKAGE=$(cat package.name)",
              "pip2 install -r dev_requirements.txt",
              "syncloud-upload.sh $NAME $DRONE_BRANCH $VERSION $PACKAGE"
            ]
        },
        {
            name: "ci-artifact",
            image: "syncloud/build-deps-" + arch,
            environment: {
                ARTIFACT_SSH_KEY: {
                    from_secret: "ARTIFACT_SSH_KEY"
                }
            },
            commands: [
                "NAME=$(cat name)",
                "PACKAGE=$(cat package.name)",
                "pip2 install -r dev_requirements.txt",
                "syncloud-upload-artifact.sh $NAME integration/log $DRONE_BUILD_NUMBER-$(dpkg --print-architecture)",
                "syncloud-upload-artifact.sh $NAME integration/screenshot $DRONE_BUILD_NUMBER-$(dpkg --print-architecture)",
                "syncloud-upload-artifact.sh $NAME $PACKAGE $DRONE_BUILD_NUMBER-$(dpkg --print-architecture)"
            ],
            when: {
              status: [ "failure", "success" ]
            }
        }
    ],
    services: [{
        name: "device",
        image: "syncloud/systemd-" + arch,
        privileged: true,
        volumes: [
            {
                name: "dbus",
                path: "/var/run/dbus"
            },
            {
                name: "dev",
                path: "/dev"
            }
        ]
    }],
    volumes: [
        {
            name: "dbus",
            host: {
                path: "/var/run/dbus"
            }
        },
        {
            name: "dev",
            host: {
                path: "/dev"
            }
        },
        {
            name: "shm",
            temp: {}
        }
    ]
};

[
    build("arm"),
    build("amd64")
]

@bradrydzewski Any advice?

Sorry, I am very busy this week and will not be able to look into this right now. If this is a pressing matter, I recommend inspecting the source at https://github.com/drone/drone/blob/master/plugin/config/jsonnet.go

Or perhaps others reading this thread will be able to provide support.

@bradrydzewski No problem thanks for helping and the great product, quick question, is it not part of open source version: https://github.com/drone/drone/blob/master/plugin/config/jsonnet_oss.go ?