GithubHelp home page GithubHelp logo

drone-plugins / drone-downstream Goto Github PK

View Code? Open in Web Editor NEW
31.0 9.0 42.0 483 KB

Drone plugin to trigger downstream repositories to build

Home Page: http://plugins.drone.io/drone-plugins/drone-downstream

License: Apache License 2.0

Go 100.00%
drone drone-plugin

drone-downstream's Introduction

drone-downstream

Build Status Gitter chat Join the discussion at https://community.harness.io/ Drone questions at https://stackoverflow.com Go Doc Go Report

Drone plugin to trigger downstream repository builds. For the usage information and a listing of the available options please take a look at the docs.

Build

Build the binary with the following command:

export GOOS=linux
export GOARCH=amd64
export CGO_ENABLED=0
export GO111MODULE=on

go build -v -a -tags netgo -o release/linux/amd64/drone-downstream

Docker

Build the Docker image with the following command:

docker build \
  --label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
  --label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
  --file docker/Dockerfile.linux.amd64 --tag plugins/downstream .

Usage

docker run --rm \
  -e PLUGIN_REPOSITORIES=octocat/Hello-World \
  -e PLUGIN_TOKEN=eyJhbFciHiJISzI1EiIsUnR5cCW6IkpXQCJ9.ezH0ZXh0LjoidGJvZXJnZXIiLCJ0eXBlIjoidXNlciJ9.1m_3QFA6eA7h4wrBby2aIRFAEhQWPrlj4dsO_Gfchtc \
  -v $(pwd):$(pwd) \
  -w $(pwd) \
  plugins/downstream

drone-downstream's People

Contributors

alikhil avatar andrewhowdencom avatar appleboy avatar bchivari avatar bradrydzewski avatar delfer avatar donny-dont avatar dschmidt avatar frapposelli avatar jackspirou avatar jesselang avatar juanluisbaptiste avatar kzaitsev avatar mozgiii avatar prabdeb avatar renovate-bot avatar rohit-gohri avatar tboerger avatar techknowlogick avatar tonglil avatar xinity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drone-downstream's Issues

Could you release a new version?

The difference between master and latest version (v1.2.0) is getting bigger: v1.2.0...master
We use the downstream plugin as a docker container and want to avoid using the latest tag,
Could you release a new version?

How to set retry time

Issues

When I use downstream plugin for triggering build for deploy my service, several repos may trigger for the same time. Is there any way to set some env like RETRY_TIME used with timeout to make sure trigger will not fail, and trigger it one by one?

[Feature Request] Trigger matching branch builds.

Trigger matching branch builds.

For example:
I have different projects that use git-flow for example and have direct co-dependency between environments by branch naming qa->qa, dev->dev,

Whenever a build happens in ProjectA in dev branch I also want to target the dev branch in the downstream ProjectB and so on for different branches

$MATCH would indicate that the name of the branch should be taken from DRONE_COMMIT_BRANCH

pipeline:
  downstream:
    image: plugins/downstream
    server: https://ci.example.com
    repositories:
      - octocat/Hello-World@$MATCH
      - octocat/Spoon-Knife@$MATCH
    when:
      event: push
      branch: [master, dev, qa]
      success: true

I'm happy to open a PR.

30x redirect from API treated as success

I found this problem when turned on force https. But have not updated server url.

Plugin is reporting that build has been triggered, but nothing happens. My idea is that client gets 30x redirect and treats it as success.

docker tag management

@tboerger

Could I ask to not override the exist tag when run a new build?

https://github.com/drone-plugins/drone-downstream/blob/master/.drone.yml#L62

 tags: [ latest, 1.0.0, 1.0, 1 ]

I recently got error with this plugins.

Error: unable to get latest build for orig/project-1

And I found there is a new docker push 12 days before.

Could you please add a new tag and push the docker image with build number, such as 1.0.<build_number>? So we can easily trace the docker image tag, when we have issue with it?

I think the same fix should be deployed to all other plungin as well.

Deadlock with 1 agent

When we press "Restart build" in Web UI, it just make POST /api/repos/.../.../builds/...?fork=true
And new build now in server's queue. But downstream plugin want to get latest build, why?
It causes Deadlock problem:

  • 1 agent
  • downstream project already in queue
  • upstream project takes the agent
  • upstream project waits for downstream (queued) to complete (never till agent busy)

Why not to disable any checks before restart build?

Error info is lost here

return fmt.Errorf("Error: unable to trigger build for %s.\n", entry)

The actual error is ignored and the resulting error message in build log is not informative.
The only way to see the actual error is to see in drone server logs.

Environment variables are not working as expected.

I am triggering my integration test pipeline after docker image build for one of the repos and using downstream trigger plugin for that.

this is my log for trigger step

with params:
4s6  - TRIGGERED_BY_REPO: repo-name
4s7  - TRIGGERED_BY_TAG: test-tag-999

but the variable TRIGGERED_BY_TAG is set as “latest” in my integration test pipeline. I had previous build with value “latest” for the same variable so I suspect there is some kind of caching.

I have already posted this at https://discourse.drone.io/ but there is no response after several days.
Any help will be appreciated.

Trigger specific function within downstream repository

I am able to trigger a downstream repository, but i would like to trigger a specific section in the downstream .drone.yml. The downstream repo has contains various functional tests and i would like to create sections in my drone file like run-functional-test-a and run-functional-test-b. Is that possible?

Support for what event to trigger

I don't see in the documentation that you can specify what event type to trigger in the downstream repo. Appears to trigger the most recent drone run , but I am interested in triggering a specific type of run, like a tag event. I'd be happy to work on a PR for that

If I'm missing seeing it somewhere, my apologies!

re-write plugin

I think this plugin needs a re-write for the following reasons:

  1. this plugin previously used the re-start API which required an existing build number in the database. This is no longer required with the addition of the build creation API [1].
  2. this plugin works around a limitation where you cannot re-start a running build and as a result has some pretty gnarly polling logic that could be completely eliminated.
  3. the wait field should be repurposed to wait for the build to complete and, if the build fails, return a non-zero exit code.

[1] https://docs.drone.io/api/builds/build_create/

Branch / build no is ignored

The latest develop branch build has a number 3.

First of all, when I did not have a build on master it was

time="2019-04-17T09:14:09Z" level=fatal msg="Error: unable to get latest build for owner/repo-name@develop.\n"

I created a build on master branch, it got number 4.

Then I try both

kind: pipeline
name: default

steps:
  - name: name
    when:
      branch:
        - master
        - develop
    image: plugins/downstream
    settings:
      server: https://drone.example.com
      token:
        from_secret: drone_token
      fork: true
      repositories:
        - owner/repo-name@develop
Starting new build 5 for owner/repo-name@develop.

and

kind: pipeline
name: default

steps:
  - name: name
    when:
      branch:
        - master
        - develop
    image: plugins/downstream
    settings:
      server: https://drone.example.com
      token:
        from_secret: drone_token
      fork: true
      repositories:
        - owner/repo-name@3
Starting new build 6 for owner/repo-name@3.

But both trigger the master build and not develop. So, I assume the @3 and @develop is simply ignored

[proposal] trigger downstream with several key/value

For my understanding, trigger drone-downstream is to run a similar drone build start command via api.

Which I need:

  1. Extra feature to trigger with several --param key=value. These key/values can be generated from preview steps in same .drone.yml
  2. Support drone deploy as well (#25), because both drone build and drone deploy supports --param key=value and I do need to trigger downsteam with drone deploy directly.

My questions are, why not use a drone-cli container to do the job directly via shell scripting, more than write a seperate Go plugin as this repo? It will support any new future features automatically from new version of drone cli drone build/deploy

So:

  1. Can Drone team lead to build drone-cli as official image when new version released? It will be better to make the old versions available as well.

  2. Rewrite this plugin (or create a new one) to accept key/value and support deploy as well

New plugin usage will be similar as below:

notify:
  downstream:
    image: plugins/downstream
    server: https://ci.example.com
    type: [build|deploy]
    param: 
      key1: ${varialbe1}
      key2: ${varialbe2}
    repositories:
      - octocat/Hello-World@develop

I am happy to work on this, but the thing to stop me is, how to transfer variables from preview step to this plugin (varialbe1 and varialbe2)?

Ability to trigger branch same current

Drone have variable $DRONE_BRANCH. In some cases (f.e. release & develop CI tree) it would be great to set branch in repositories like that:

  trigger_next_stage_release:
    image: plugins/downstream
    server: https://drone.ts-t.ru
    fork: true
    repositories:
      - SomeOwner/some-project@$DRONE_BRANCH
    secrets: [ downstream_token ]
    when:
      event: [ tag, push ]
      branch: [ release/*, release*, master ]

But now it doesn't work:

time="2019-01-10T05:14:25Z" level=fatal msg="Error: unable to get latest build for SomeOwner/some-project@$DRONE_BRANCH.\n"

downstream not working as plugin

Downloading the downstream plugin docker container is working for me as follows:

docker run -i plugins/drone-downstream <<EOF
{
    "system": {
        "link_url": "http://drone.server.com"
    },
    "vargs": {
        "repositories": [
            "org/repo"
        ],
        "Server": "http://drone.server.com",
        "token": <TOKEN>
    }
}
EOF

but I am unable to trigger a downstream build using the same arguments in drone:

notify:
  downstream:
    server: "http://drone.server.com"
    repositories:
      - org/repo
    token: $$DRONE_API_TOKEN
    when:
      event: push
      branch: master
      success: true

There is no error output from the build either. I have confirmed the notify step is working by adding a hipchat notification step.

Extract `server` setting from environment variables

Drone automatically exposes the following environment variables containing the drone server:

DRONE_SYSTEM_HOST=drone.exmaple.com
DRONE_SYSTEM_HOSTNAME=drone.exmaple.com
DRONE_BUILD_LINK=https://drone.exmaple.com/repo-owner/repo-name/42

I think it would be possible to extract the server setting from DRONE_BUILD_LINK (because that also includes the protocol and port). Then the server setting would be optional.

It would make it easier to configure the .drone.yml and would make it more generally applicable and more independent of the particular network setup.

If this is feature is already implemented, please add a note to the docs (http://plugins.drone.io/fr/drone-plugins/drone-downstream/).

Error: unable to get latest build for orig/project-1

Run well with plugins/downstream image for several months, suddenly it doesn't work with this error

Error: unable to get latest build for orig/project-1

I found the image tags in hub.docker.com was updated 12 days ago. So is it related new commit recently in this repo?

My downstream pipeline:

 notify_downstream_repositories:
   image: plugins/downstream
   server: https://drone.example.io
   secrets: [ downstream_token ]
   fork: true
   repositories:
         - orig/project-1

Can't restart running task

Expected
build restarted
or
new build in poarallel or in queue

Got

Error: unable to trigger build for aaa/bbb.

The same with or w/o PLUGIN_FORK=true

docker run --rm -e PLUGIN_SERVER=https://drone.xxx -e PLUGIN_REPOSITORIES=YYY/zzz -e PLUGIN_TOKEN=mmm -e PLUGIN_FORK=true plugins/downstream

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.