2021-10-03 15:07:39 +02:00
|
|
|
// Copyright 2021 Woodpecker Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package exec
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2021-10-27 21:03:14 +02:00
|
|
|
"github.com/urfave/cli/v2"
|
2021-12-19 13:46:36 +02:00
|
|
|
|
2023-12-08 09:15:08 +02:00
|
|
|
"go.woodpecker-ci.org/woodpecker/v2/shared/constant"
|
2021-10-03 15:07:39 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var flags = []cli.Flag{
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.BoolFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_LOCAL"},
|
|
|
|
Name: "local",
|
2022-10-18 03:24:12 +02:00
|
|
|
Usage: "run from local directory",
|
2021-10-27 21:03:14 +02:00
|
|
|
Value: true,
|
|
|
|
},
|
|
|
|
&cli.DurationFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_TIMEOUT"},
|
|
|
|
Name: "timeout",
|
2022-10-18 03:24:12 +02:00
|
|
|
Usage: "pipeline timeout",
|
2021-10-27 21:03:14 +02:00
|
|
|
Value: time.Hour,
|
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_VOLUMES"},
|
|
|
|
Name: "volumes",
|
2022-10-18 03:24:12 +02:00
|
|
|
Usage: "pipeline volumes",
|
2021-10-27 21:03:14 +02:00
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_NETWORKS"},
|
|
|
|
Name: "network",
|
|
|
|
Usage: "external networks",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2022-02-26 04:02:42 +02:00
|
|
|
EnvVars: []string{"WOODPECKER_PREFIX"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "prefix",
|
|
|
|
Value: "woodpecker",
|
2022-02-26 04:02:42 +02:00
|
|
|
Usage: "prefix used for containers, volumes, networks, ... created by woodpecker",
|
2021-10-27 21:03:14 +02:00
|
|
|
Hidden: true,
|
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
2021-10-03 15:07:39 +02:00
|
|
|
Name: "privileged",
|
|
|
|
Usage: "privileged plugins",
|
2021-12-19 13:46:36 +02:00
|
|
|
Value: cli.NewStringSlice(constant.PrivilegedPlugins...),
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2022-02-26 04:02:42 +02:00
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_BACKEND"},
|
|
|
|
Name: "backend-engine",
|
|
|
|
Usage: "backend engine to run pipelines on",
|
|
|
|
Value: "auto-detect",
|
|
|
|
},
|
2021-10-03 15:07:39 +02:00
|
|
|
|
2023-08-07 21:13:26 +02:00
|
|
|
//
|
|
|
|
// backend options for pipeline compiler
|
|
|
|
//
|
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_BACKEND_NO_PROXY", "NO_PROXY", "no_proxy"},
|
|
|
|
Usage: "if set, pass the environment variable down as \"NO_PROXY\" to steps",
|
|
|
|
Name: "backend-no-proxy",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_BACKEND_HTTP_PROXY", "HTTP_PROXY", "http_proxy"},
|
2023-08-19 16:27:21 +02:00
|
|
|
Usage: "if set, pass the environment variable down as \"HTTP_PROXY\" to steps",
|
2023-08-07 21:13:26 +02:00
|
|
|
Name: "backend-http-proxy",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_BACKEND_HTTPS_PROXY", "HTTPS_PROXY", "https_proxy"},
|
|
|
|
Usage: "if set, pass the environment variable down as \"HTTPS_PROXY\" to steps",
|
|
|
|
Name: "backend-https-proxy",
|
|
|
|
},
|
|
|
|
|
2021-10-03 15:07:39 +02:00
|
|
|
//
|
|
|
|
// Please note the below flags should match the flags from
|
|
|
|
// pipeline/frontend/metadata.go and should be kept synchronized.
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// workspace default
|
|
|
|
//
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_WORKSPACE_BASE"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "workspace-base",
|
|
|
|
Value: "/woodpecker",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_WORKSPACE_PATH"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "workspace-path",
|
|
|
|
Value: "src",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
|
|
|
//
|
|
|
|
// netrc parameters
|
|
|
|
//
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_NETRC_USERNAME"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "netrc-username",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_NETRC_PASSWORD"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "netrc-password",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_NETRC_MACHINE"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "netrc-machine",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
|
|
|
//
|
|
|
|
// metadata parameters
|
|
|
|
//
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2022-05-31 01:12:18 +02:00
|
|
|
EnvVars: []string{"CI_SYSTEM_PLATFORM"},
|
|
|
|
Name: "system-platform",
|
2021-10-27 21:03:14 +02:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_SYSTEM_NAME"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "system-name",
|
2022-09-27 22:19:39 +02:00
|
|
|
Value: "woodpecker",
|
2021-10-27 21:03:14 +02:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2023-07-28 14:58:20 +02:00
|
|
|
EnvVars: []string{"CI_SYSTEM_URL"},
|
2023-11-14 18:12:12 +02:00
|
|
|
Name: "system-url",
|
2022-09-27 22:19:39 +02:00
|
|
|
Value: "https://github.com/woodpecker-ci/woodpecker",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2023-06-05 00:15:07 +02:00
|
|
|
EnvVars: []string{"CI_REPO"},
|
|
|
|
Name: "repo",
|
|
|
|
Usage: "full repo name",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"CI_REPO_REMOTE_ID"},
|
|
|
|
Name: "repo-remote-id",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2023-07-28 14:58:20 +02:00
|
|
|
EnvVars: []string{"CI_REPO_URL"},
|
2023-11-14 18:12:12 +02:00
|
|
|
Name: "repo-url",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2023-07-28 14:58:20 +02:00
|
|
|
EnvVars: []string{"CI_REPO_CLONE_URL"},
|
2022-11-05 01:35:06 +02:00
|
|
|
Name: "repo-clone-url",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2023-08-12 17:39:13 +02:00
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"CI_REPO_CLONE_SSH_URL"},
|
|
|
|
Name: "repo-clone-ssh-url",
|
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_REPO_PRIVATE"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "repo-private",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2023-06-05 00:15:07 +02:00
|
|
|
&cli.BoolFlag{
|
|
|
|
EnvVars: []string{"CI_REPO_TRUSTED"},
|
|
|
|
Name: "repo-trusted",
|
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.IntFlag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PIPELINE_NUMBER"},
|
|
|
|
Name: "pipeline-number",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.IntFlag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PIPELINE_PARENT"},
|
|
|
|
Name: "pipeline-parent",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.Int64Flag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PIPELINE_CREATED"},
|
|
|
|
Name: "pipeline-created",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.Int64Flag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PIPELINE_STARTED"},
|
|
|
|
Name: "pipeline-started",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.Int64Flag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PIPELINE_FINISHED"},
|
|
|
|
Name: "pipeline-finished",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PIPELINE_STATUS"},
|
|
|
|
Name: "pipeline-status",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PIPELINE_EVENT"},
|
|
|
|
Name: "pipeline-event",
|
2022-09-27 12:02:32 +02:00
|
|
|
Value: "manual",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2023-07-28 14:58:20 +02:00
|
|
|
EnvVars: []string{"CI_PIPELINE_URL"},
|
2023-11-14 18:12:12 +02:00
|
|
|
Name: "pipeline-url",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PIPELINE_TARGET"},
|
|
|
|
Name: "pipeline-target",
|
2021-10-27 21:03:14 +02:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_COMMIT_SHA"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "commit-sha",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_COMMIT_REF"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "commit-ref",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_COMMIT_REFSPEC"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "commit-refspec",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_COMMIT_BRANCH"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "commit-branch",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_COMMIT_MESSAGE"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "commit-message",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_COMMIT_AUTHOR_NAME"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "commit-author-name",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_COMMIT_AUTHOR_AVATAR"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "commit-author-avatar",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_COMMIT_AUTHOR_EMAIL"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "commit-author-email",
|
|
|
|
},
|
|
|
|
&cli.IntFlag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_NUMBER"},
|
|
|
|
Name: "prev-pipeline-number",
|
2021-10-27 21:03:14 +02:00
|
|
|
},
|
|
|
|
&cli.Int64Flag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_CREATED"},
|
|
|
|
Name: "prev-pipeline-created",
|
2021-10-27 21:03:14 +02:00
|
|
|
},
|
|
|
|
&cli.Int64Flag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_STARTED"},
|
|
|
|
Name: "prev-pipeline-started",
|
2021-10-27 21:03:14 +02:00
|
|
|
},
|
|
|
|
&cli.Int64Flag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_FINISHED"},
|
|
|
|
Name: "prev-pipeline-finished",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_STATUS"},
|
|
|
|
Name: "prev-pipeline-status",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2022-10-18 03:24:12 +02:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_EVENT"},
|
|
|
|
Name: "prev-pipeline-event",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2023-07-28 14:58:20 +02:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_URL"},
|
2023-11-14 18:12:12 +02:00
|
|
|
Name: "prev-pipeline-url",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_SHA"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "prev-commit-sha",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_REF"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "prev-commit-ref",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_REFSPEC"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "prev-commit-refspec",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_BRANCH"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "prev-commit-branch",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_MESSAGE"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "prev-commit-message",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_AUTHOR_NAME"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "prev-commit-author-name",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_AUTHOR_AVATAR"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "prev-commit-author-avatar",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_AUTHOR_EMAIL"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "prev-commit-author-email",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.IntFlag{
|
2023-04-08 13:15:28 +02:00
|
|
|
EnvVars: []string{"CI_WORKFLOW_NAME"},
|
|
|
|
Name: "workflow-name",
|
|
|
|
},
|
|
|
|
&cli.IntFlag{
|
2023-07-28 14:58:20 +02:00
|
|
|
EnvVars: []string{"CI_WORKFLOW_NUMBER"},
|
2023-04-08 13:15:28 +02:00
|
|
|
Name: "workflow-number",
|
|
|
|
},
|
|
|
|
&cli.IntFlag{
|
2023-07-28 14:58:20 +02:00
|
|
|
EnvVars: []string{"CI_STEP_NAME"},
|
2023-04-08 13:15:28 +02:00
|
|
|
Name: "step-name",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2021-10-27 21:03:14 +02:00
|
|
|
&cli.StringSliceFlag{
|
2021-11-25 21:43:31 +02:00
|
|
|
EnvVars: []string{"CI_ENV"},
|
2021-10-27 21:03:14 +02:00
|
|
|
Name: "env",
|
2021-10-03 15:07:39 +02:00
|
|
|
},
|
2023-06-05 00:15:07 +02:00
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"CI_FORGE_TYPE"},
|
|
|
|
Name: "forge-type",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"CI_FORGE_URL"},
|
|
|
|
Name: "forge-url",
|
|
|
|
},
|
2021-10-03 15:07:39 +02:00
|
|
|
}
|