mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-29 21:31:02 +00:00
Add dedicated DroneCI env compatibility layer (#1185)
for more info see `https://github.com/drone-plugins/drone-plugin-lib/pull/37/files` and c79d49c862
This commit is contained in:
parent
afb02d2dd5
commit
795bbd8988
2 changed files with 75 additions and 0 deletions
59
pipeline/frontend/drone_compatibility.go
Normal file
59
pipeline/frontend/drone_compatibility.go
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
// Copyright 2022 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 frontend
|
||||||
|
|
||||||
|
// setDroneEnviron set dedicated to DroneCI environment vars as compatibility layer
|
||||||
|
func (m *Metadata) setDroneEnviron(env map[string]string) {
|
||||||
|
// webhook
|
||||||
|
env["DRONE_BRANCH"] = env["CI_COMMIT_BRANCH"]
|
||||||
|
env["DRONE_PULL_REQUEST"] = env["CI_COMMIT_PULL_REQUEST"]
|
||||||
|
env["DRONE_TAG"] = env["CI_COMMIT_TAG"]
|
||||||
|
env["DRONE_SOURCE_BRANCH"] = env["CI_COMMIT_SOURCE_BRANCH"]
|
||||||
|
env["DRONE_TARGET_BRANCH"] = env["CI_COMMIT_TARGET_BRANCH"]
|
||||||
|
// build
|
||||||
|
env["DRONE_BUILD_NUMBER"] = env["CI_BUILD_NUMBER"]
|
||||||
|
env["DRONE_BUILD_PARENT"] = env["CI_BUILD_PARENT"]
|
||||||
|
env["DRONE_BUILD_EVENT"] = env["CI_BUILD_EVENT"]
|
||||||
|
env["DRONE_BUILD_STATUS"] = env["CI_BUILD_STATUS"]
|
||||||
|
env["DRONE_BUILD_LINK"] = env["CI_BUILD_LINK"]
|
||||||
|
env["DRONE_BUILD_CREATED"] = env["CI_BUILD_CREATED"]
|
||||||
|
env["DRONE_BUILD_STARTED"] = env["CI_BUILD_STARTED"]
|
||||||
|
env["DRONE_BUILD_FINISHED"] = env["CI_BUILD_FINISHED"]
|
||||||
|
// commit
|
||||||
|
env["DRONE_COMMIT"] = env["CI_COMMIT_SHA"]
|
||||||
|
env["DRONE_COMMIT_BEFORE"] = env["CI_PREV_COMMIT_SHA"]
|
||||||
|
env["DRONE_COMMIT_REF"] = env["CI_COMMIT_REF"]
|
||||||
|
env["DRONE_COMMIT_BRANCH"] = env["CI_COMMIT_BRANCH"]
|
||||||
|
env["DRONE_COMMIT_LINK"] = env["CI_COMMIT_LINK"]
|
||||||
|
env["DRONE_COMMIT_MESSAGE"] = env["CI_COMMIT_MESSAGE"]
|
||||||
|
env["DRONE_COMMIT_AUTHOR"] = env["CI_COMMIT_AUTHOR"]
|
||||||
|
env["DRONE_COMMIT_AUTHOR_NAME"] = env["CI_COMMIT_AUTHOR"]
|
||||||
|
env["DRONE_COMMIT_AUTHOR_EMAIL"] = env["CI_COMMIT_AUTHOR_EMAIL"]
|
||||||
|
env["DRONE_COMMIT_AUTHOR_AVATAR"] = env["CI_COMMIT_AUTHOR_AVATAR"]
|
||||||
|
// repo
|
||||||
|
env["DRONE_REPO"] = env["CI_REPO"]
|
||||||
|
env["DRONE_REPO_SCM"] = env["CI_REPO_SCM"]
|
||||||
|
env["DRONE_REPO_OWNER"] = env["CI_REPO_OWNER"]
|
||||||
|
env["DRONE_REPO_NAME"] = env["CI_REPO_NAME"]
|
||||||
|
env["DRONE_REPO_LINK"] = env["CI_REPO_LINK"]
|
||||||
|
env["DRONE_REPO_BRANCH"] = env["CI_REPO_DEFAULT_BRANCH"]
|
||||||
|
env["DRONE_REPO_PRIVATE"] = env["CI_REPO_PRIVATE"]
|
||||||
|
// clone
|
||||||
|
env["DRONE_REMOTE_URL"] = env["CI_REPO_REMOTE"]
|
||||||
|
env["DRONE_GIT_HTTP_URL"] = env["CI_REPO_REMOTE"]
|
||||||
|
// misc
|
||||||
|
env["DRONE_SYSTEM_HOST"] = env["CI_SYSTEM_HOST"]
|
||||||
|
env["DRONE_STEP_NUMBER"] = env["CI_JOB_NUMBER"]
|
||||||
|
}
|
|
@ -1,3 +1,17 @@
|
||||||
|
// Copyright 2022 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 frontend
|
package frontend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -197,6 +211,8 @@ func (m *Metadata) Environ() map[string]string {
|
||||||
params["CI_COMMIT_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref)
|
params["CI_COMMIT_PULL_REQUEST"] = pullRegexp.FindString(m.Curr.Commit.Ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.setDroneEnviron(params)
|
||||||
|
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue