2021-10-03 13:07:39 +00: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 19:03:14 +00:00
|
|
|
"github.com/urfave/cli/v2"
|
2021-12-19 11:46:36 +00:00
|
|
|
|
2023-12-08 07:15:08 +00:00
|
|
|
"go.woodpecker-ci.org/woodpecker/v2/shared/constant"
|
2021-10-03 13:07:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var flags = []cli.Flag{
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.BoolFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_LOCAL"},
|
|
|
|
Name: "local",
|
2022-10-18 01:24:12 +00:00
|
|
|
Usage: "run from local directory",
|
2021-10-27 19:03:14 +00:00
|
|
|
Value: true,
|
|
|
|
},
|
2024-03-20 23:19:48 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_REPO_PATH"},
|
|
|
|
Name: "repo-path",
|
|
|
|
Usage: "path to local repository",
|
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.DurationFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_TIMEOUT"},
|
|
|
|
Name: "timeout",
|
2022-10-18 01:24:12 +00:00
|
|
|
Usage: "pipeline timeout",
|
2021-10-27 19:03:14 +00:00
|
|
|
Value: time.Hour,
|
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_VOLUMES"},
|
|
|
|
Name: "volumes",
|
2022-10-18 01:24:12 +00:00
|
|
|
Usage: "pipeline volumes",
|
2021-10-27 19:03:14 +00:00
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_NETWORKS"},
|
|
|
|
Name: "network",
|
|
|
|
Usage: "external networks",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2022-02-26 02:02:42 +00:00
|
|
|
EnvVars: []string{"WOODPECKER_PREFIX"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "prefix",
|
|
|
|
Value: "woodpecker",
|
2022-02-26 02:02:42 +00:00
|
|
|
Usage: "prefix used for containers, volumes, networks, ... created by woodpecker",
|
2021-10-27 19:03:14 +00:00
|
|
|
Hidden: true,
|
|
|
|
},
|
|
|
|
&cli.StringSliceFlag{
|
2021-10-03 13:07:39 +00:00
|
|
|
Name: "privileged",
|
|
|
|
Usage: "privileged plugins",
|
2021-12-19 11:46:36 +00:00
|
|
|
Value: cli.NewStringSlice(constant.PrivilegedPlugins...),
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2022-02-26 02:02:42 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_BACKEND"},
|
|
|
|
Name: "backend-engine",
|
|
|
|
Usage: "backend engine to run pipelines on",
|
|
|
|
Value: "auto-detect",
|
|
|
|
},
|
2021-10-03 13:07:39 +00:00
|
|
|
|
2023-08-07 19:13:26 +00: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 14:27:21 +00:00
|
|
|
Usage: "if set, pass the environment variable down as \"HTTP_PROXY\" to steps",
|
2023-08-07 19:13:26 +00: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 13:07:39 +00: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 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_WORKSPACE_BASE"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "workspace-base",
|
|
|
|
Value: "/woodpecker",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_WORKSPACE_PATH"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "workspace-path",
|
|
|
|
Value: "src",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
|
|
|
//
|
|
|
|
// netrc parameters
|
|
|
|
//
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_NETRC_USERNAME"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "netrc-username",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_NETRC_PASSWORD"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "netrc-password",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_NETRC_MACHINE"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "netrc-machine",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
|
|
|
//
|
|
|
|
// metadata parameters
|
|
|
|
//
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2022-05-30 23:12:18 +00:00
|
|
|
EnvVars: []string{"CI_SYSTEM_PLATFORM"},
|
|
|
|
Name: "system-platform",
|
2021-10-27 19:03:14 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_SYSTEM_NAME"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "system-name",
|
2022-09-27 20:19:39 +00:00
|
|
|
Value: "woodpecker",
|
2021-10-27 19:03:14 +00:00
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2023-07-28 12:58:20 +00:00
|
|
|
EnvVars: []string{"CI_SYSTEM_URL"},
|
2023-11-14 16:12:12 +00:00
|
|
|
Name: "system-url",
|
2022-09-27 20:19:39 +00:00
|
|
|
Value: "https://github.com/woodpecker-ci/woodpecker",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2023-06-04 22:15:07 +00: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 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2023-07-28 12:58:20 +00:00
|
|
|
EnvVars: []string{"CI_REPO_URL"},
|
2023-11-14 16:12:12 +00:00
|
|
|
Name: "repo-url",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2023-07-28 12:58:20 +00:00
|
|
|
EnvVars: []string{"CI_REPO_CLONE_URL"},
|
2022-11-04 23:35:06 +00:00
|
|
|
Name: "repo-clone-url",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2023-08-12 15:39:13 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"CI_REPO_CLONE_SSH_URL"},
|
|
|
|
Name: "repo-clone-ssh-url",
|
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_REPO_PRIVATE"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "repo-private",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2023-06-04 22:15:07 +00:00
|
|
|
&cli.BoolFlag{
|
|
|
|
EnvVars: []string{"CI_REPO_TRUSTED"},
|
|
|
|
Name: "repo-trusted",
|
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.IntFlag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PIPELINE_NUMBER"},
|
|
|
|
Name: "pipeline-number",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.IntFlag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PIPELINE_PARENT"},
|
|
|
|
Name: "pipeline-parent",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.Int64Flag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PIPELINE_CREATED"},
|
|
|
|
Name: "pipeline-created",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.Int64Flag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PIPELINE_STARTED"},
|
|
|
|
Name: "pipeline-started",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.Int64Flag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PIPELINE_FINISHED"},
|
|
|
|
Name: "pipeline-finished",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PIPELINE_STATUS"},
|
|
|
|
Name: "pipeline-status",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PIPELINE_EVENT"},
|
|
|
|
Name: "pipeline-event",
|
2022-09-27 10:02:32 +00:00
|
|
|
Value: "manual",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2023-07-28 12:58:20 +00:00
|
|
|
EnvVars: []string{"CI_PIPELINE_URL"},
|
2023-11-14 16:12:12 +00:00
|
|
|
Name: "pipeline-url",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PIPELINE_TARGET"},
|
|
|
|
Name: "pipeline-target",
|
2021-10-27 19:03:14 +00:00
|
|
|
},
|
2024-05-02 16:56:19 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"CI_PIPELINE_TASK"},
|
|
|
|
Name: "pipeline-task",
|
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_COMMIT_SHA"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "commit-sha",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_COMMIT_REF"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "commit-ref",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_COMMIT_REFSPEC"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "commit-refspec",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_COMMIT_BRANCH"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "commit-branch",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_COMMIT_MESSAGE"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "commit-message",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_COMMIT_AUTHOR_NAME"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "commit-author-name",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_COMMIT_AUTHOR_AVATAR"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "commit-author-avatar",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_COMMIT_AUTHOR_EMAIL"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "commit-author-email",
|
|
|
|
},
|
|
|
|
&cli.IntFlag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_NUMBER"},
|
|
|
|
Name: "prev-pipeline-number",
|
2021-10-27 19:03:14 +00:00
|
|
|
},
|
|
|
|
&cli.Int64Flag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_CREATED"},
|
|
|
|
Name: "prev-pipeline-created",
|
2021-10-27 19:03:14 +00:00
|
|
|
},
|
|
|
|
&cli.Int64Flag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_STARTED"},
|
|
|
|
Name: "prev-pipeline-started",
|
2021-10-27 19:03:14 +00:00
|
|
|
},
|
|
|
|
&cli.Int64Flag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_FINISHED"},
|
|
|
|
Name: "prev-pipeline-finished",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_STATUS"},
|
|
|
|
Name: "prev-pipeline-status",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_EVENT"},
|
|
|
|
Name: "prev-pipeline-event",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2023-07-28 12:58:20 +00:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_URL"},
|
2023-11-14 16:12:12 +00:00
|
|
|
Name: "prev-pipeline-url",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_SHA"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "prev-commit-sha",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_REF"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "prev-commit-ref",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_REFSPEC"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "prev-commit-refspec",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_BRANCH"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "prev-commit-branch",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_MESSAGE"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "prev-commit-message",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_AUTHOR_NAME"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "prev-commit-author-name",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_AUTHOR_AVATAR"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "prev-commit-author-avatar",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_PREV_COMMIT_AUTHOR_EMAIL"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "prev-commit-author-email",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.IntFlag{
|
2023-04-08 11:15:28 +00:00
|
|
|
EnvVars: []string{"CI_WORKFLOW_NAME"},
|
|
|
|
Name: "workflow-name",
|
|
|
|
},
|
|
|
|
&cli.IntFlag{
|
2023-07-28 12:58:20 +00:00
|
|
|
EnvVars: []string{"CI_WORKFLOW_NUMBER"},
|
2023-04-08 11:15:28 +00:00
|
|
|
Name: "workflow-number",
|
|
|
|
},
|
|
|
|
&cli.IntFlag{
|
2023-07-28 12:58:20 +00:00
|
|
|
EnvVars: []string{"CI_STEP_NAME"},
|
2023-04-08 11:15:28 +00:00
|
|
|
Name: "step-name",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringSliceFlag{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_ENV"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "env",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2023-06-04 22:15:07 +00:00
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"CI_FORGE_TYPE"},
|
|
|
|
Name: "forge-type",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"CI_FORGE_URL"},
|
|
|
|
Name: "forge-url",
|
|
|
|
},
|
2021-10-03 13:07:39 +00:00
|
|
|
}
|