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
|
|
|
|
|
|
|
"github.com/woodpecker-ci/woodpecker/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,
|
|
|
|
},
|
|
|
|
&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
|
|
|
|
|
|
|
//
|
|
|
|
// 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{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_SYSTEM_LINK"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "system-link",
|
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{
|
2021-11-25 19:43:31 +00:00
|
|
|
EnvVars: []string{"CI_REPO_NAME"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "repo-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_REPO_LINK"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "repo-link",
|
2021-10-03 13:07:39 +00:00
|
|
|
},
|
2021-10-27 19:03:14 +00:00
|
|
|
&cli.StringFlag{
|
2022-11-04 23:35:06 +00:00
|
|
|
EnvVars: []string{"CI_REPO_CLONE_URL", "CI_REPO_REMOTE"},
|
|
|
|
Name: "repo-clone-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_REPO_PRIVATE"},
|
2021-10-27 19:03:14 +00:00
|
|
|
Name: "repo-private",
|
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_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{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PIPELINE_LINK"},
|
|
|
|
Name: "pipeline-link",
|
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
|
|
|
},
|
|
|
|
&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{
|
2022-10-18 01:24:12 +00:00
|
|
|
EnvVars: []string{"CI_PREV_PIPELINE_LINK"},
|
|
|
|
Name: "prev-pipeline-link",
|
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{
|
2022-10-28 15:38:53 +00:00
|
|
|
EnvVars: []string{"CI_STEP_NUMBER", "CI_JOB_NUMBER"},
|
|
|
|
Name: "step-number",
|
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
|
|
|
},
|
2022-09-05 04:01:14 +00:00
|
|
|
|
|
|
|
// TODO: add flags of backends
|
|
|
|
|
|
|
|
// backend k8s
|
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_BACKEND_K8S_NAMESPACE"},
|
|
|
|
Name: "backend-k8s-namespace",
|
|
|
|
Usage: "backend k8s namespace",
|
|
|
|
Value: "woodpecker",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_BACKEND_K8S_VOLUME_SIZE"},
|
|
|
|
Name: "backend-k8s-volume-size",
|
|
|
|
Usage: "backend k8s volume size (default 10G)",
|
|
|
|
Value: "10G",
|
|
|
|
},
|
|
|
|
&cli.StringFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_BACKEND_K8S_STORAGE_CLASS"},
|
|
|
|
Name: "backend-k8s-storage-class",
|
|
|
|
Usage: "backend k8s storage class",
|
|
|
|
Value: "",
|
|
|
|
},
|
|
|
|
&cli.BoolFlag{
|
|
|
|
EnvVars: []string{"WOODPECKER_BACKEND_K8S_STORAGE_RWX"},
|
|
|
|
Name: "backend-k8s-storage-rwx",
|
|
|
|
Usage: "backend k8s storage access mode, should ReadWriteMany (RWX) instead of ReadWriteOnce (RWO) be used? (default: true)",
|
|
|
|
Value: true,
|
|
|
|
},
|
2021-10-03 13:07:39 +00:00
|
|
|
}
|