woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.28k stars 369 forks source link

Templates for manual workflows env vars #3326

Open CodeDoctorDE opened 9 months ago

CodeDoctorDE commented 9 months ago

Clear and concise description of the problem

When running many manual workflows, it is not very handy to input the keys on every run.

Suggested solution

Create a system for github action like form where you add default values, checkboxes and more. image The syntax should be like in github actions:

    inputs:
      next_version:
        default: "0.0.0"
        description: "The next version to be released"
        required: false
      stable:
        default: false
        description: "Is this version stable?"
        type: boolean
        required: false

Maybe adding an extra type of event for tis.

Alternative

No response

Additional context

No response

Validations

zc-devs commented 9 months ago

I propose to just display ENV vars from workflow and set default value defined in yaml.

 steps:
   - name: build
     image: golang
     environment:
       - CGO=0
       - GOOS=linux
       - GOARCH=amd64
       - DISABLE_CACHE
     commands:
       - go build
       - go test

Screenshot 2024-02-05

CodeDoctorDE commented 9 months ago

Yeah this could be useful. Maybe we should make a opt-in/out for this for internal env vars?

zc-devs commented 9 months ago

make a opt-in/out for this for internal env vars?

Do you mean built-in-environment-variables? I'm afraid, it is not gonna work. Just look, how much vars Server sends to Agent :) (if you on Kubernetes, just describe pod).

CodeDoctorDE commented 9 months ago

No I mean if you define env vars in your workflow you should be able to opt out of this new feature

smainz commented 9 months ago

Just one thing to consider:

We are using the manual pipeline execution to perform builds too, but there are much more environment variables in the steps than need to be set / overriden while performing a build / deployment.

Would a config like

   environement-input: 
     - BUILD_NUMER: <proposed value>
       MATCH_REX: <some regex to validate the input>

be an option?

At the moment we have a seperate step to validate the ENV vars to overcome typos.

CodeDoctorDE commented 9 months ago

That looks good. In the future we could expand this by adding dropdowns with values: ["one", "two", "three"]

zc-devs commented 9 months ago

I'm thinking towards having special syntax for inputs now as both of you have mentioned. I've just looked at one of my pipelines:

# Environments
# SKIP_PACKAGE=true|false - skip package step
# APP_TAG=0.0.1 - override CI_COMMIT_TAG var, application release version

steps:
  set-env:
    image: debian:bookworm-slim
    commands:
      - .cicd/set-env.sh
  package:
    when:
      evaluate: 'SKIP_PACKAGE != "true"'
    image: python:3.12.1-slim-bookworm
    commands:
      - .cicd/package.sh
    secrets:
      - twine_username
      - twine_password

As we can see, I use variables that aren't defined in environment sections. Some of them are not used in pipeline definition even. Furthermore, your variants would make possible enums

dropdowns with values: ["one", "two", "three"]