mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-02 21:58:43 +00:00
Refspec had the source and target branches already. Now they got their dedicated vars
This commit is contained in:
parent
85d8b16f90
commit
3c8e95f230
2 changed files with 17 additions and 11 deletions
|
@ -6,9 +6,6 @@ pipeline:
|
||||||
test:
|
test:
|
||||||
image: golang:1.12.4
|
image: golang:1.12.4
|
||||||
commands:
|
commands:
|
||||||
- echo $CI_COMMIT_REF
|
|
||||||
- echo $CI_COMMIT_REFSPEC
|
|
||||||
- echo $DRONE_BRANCH
|
|
||||||
- go test -cover -timeout 30s $(go list ./...)
|
- go test -cover -timeout 30s $(go list ./...)
|
||||||
|
|
||||||
test_postgres:
|
test_postgres:
|
||||||
|
|
|
@ -162,17 +162,26 @@ func (m *Metadata) EnvironDrone() map[string]string {
|
||||||
// * DRONE_YAML_VERIFIED
|
// * DRONE_YAML_VERIFIED
|
||||||
// * DRONE_YAML_VERIFIED
|
// * DRONE_YAML_VERIFIED
|
||||||
var (
|
var (
|
||||||
owner string
|
owner string
|
||||||
name string
|
name string
|
||||||
|
sourceBranch string
|
||||||
|
targetBranch string
|
||||||
|
|
||||||
parts = strings.Split(m.Repo.Name, "/")
|
repoParts = strings.Split(m.Repo.Name, "/")
|
||||||
|
branchParts = strings.Split(m.Curr.Commit.Refspec, ":")
|
||||||
)
|
)
|
||||||
if len(parts) == 2 {
|
if len(repoParts) == 2 {
|
||||||
owner = strings.Split(m.Repo.Name, "/")[0]
|
owner = repoParts[0]
|
||||||
name = strings.Split(m.Repo.Name, "/")[1]
|
name = repoParts[1]
|
||||||
} else {
|
} else {
|
||||||
name = m.Repo.Name
|
name = m.Repo.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(branchParts) == 2 {
|
||||||
|
sourceBranch = branchParts[0]
|
||||||
|
targetBranch = branchParts[1]
|
||||||
|
}
|
||||||
|
|
||||||
params := map[string]string{
|
params := map[string]string{
|
||||||
"CI": "drone",
|
"CI": "drone",
|
||||||
"DRONE": "true",
|
"DRONE": "true",
|
||||||
|
@ -205,8 +214,8 @@ func (m *Metadata) EnvironDrone() map[string]string {
|
||||||
"DRONE_JOB_NUMBER": fmt.Sprintf("%d", m.Job.Number),
|
"DRONE_JOB_NUMBER": fmt.Sprintf("%d", m.Job.Number),
|
||||||
"DRONE_JOB_STARTED": fmt.Sprintf("%d", m.Curr.Started), // ISSUE: no job started
|
"DRONE_JOB_STARTED": fmt.Sprintf("%d", m.Curr.Started), // ISSUE: no job started
|
||||||
"DRONE_BRANCH": m.Curr.Commit.Branch,
|
"DRONE_BRANCH": m.Curr.Commit.Branch,
|
||||||
"DRONE_TARGET_BRANCH": m.Curr.Commit.Branch,
|
"DRONE_SOURCE_BRANCH": sourceBranch,
|
||||||
"DRONE_SOURCE_BRANCH": m.Curr.Commit.Branch,
|
"DRONE_TARGET_BRANCH": targetBranch,
|
||||||
"DRONE_COMMIT": m.Curr.Commit.Sha,
|
"DRONE_COMMIT": m.Curr.Commit.Sha,
|
||||||
"DRONE_VERSION": m.Sys.Version,
|
"DRONE_VERSION": m.Sys.Version,
|
||||||
"DRONE_DEPLOY_TO": m.Curr.Target,
|
"DRONE_DEPLOY_TO": m.Curr.Target,
|
||||||
|
|
Loading…
Reference in a new issue