diff --git a/CHANGELOG.md b/CHANGELOG.md index acb31d6..5e4b1c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ## Unreleased - Add AWS CodeBuild detection support. - Allow late static binding in `CiDetector::fromEnvironment()` when inheriting the class. +- Fix branch detection in PR builds on AppVeyor, Buddy and GitHub Actions (target branch of the PR was returned instead). ## 3.3.0 - 2020-03-06 - Allow injecting instance of `Env` using `CiDetector::fromEnvironment()` (useful for environment mocking in unit tests). diff --git a/src/Ci/AppVeyor.php b/src/Ci/AppVeyor.php index 25cd3a6..bb0863e 100644 --- a/src/Ci/AppVeyor.php +++ b/src/Ci/AppVeyor.php @@ -46,8 +46,13 @@ public function getGitCommit(): string public function getGitBranch(): string { - // For PR builds this is the base branch (not the PR branch) - return $this->env->getString('APPVEYOR_REPO_BRANCH'); + $prBranch = $this->env->getString('APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH'); + + if ($this->isPullRequest()->no() || empty($prBranch)) { + return $this->env->getString('APPVEYOR_REPO_BRANCH'); + } + + return $prBranch; } public function getRepositoryName(): string diff --git a/src/Ci/Bamboo.php b/src/Ci/Bamboo.php index bc2e6a2..d415cae 100644 --- a/src/Ci/Bamboo.php +++ b/src/Ci/Bamboo.php @@ -40,6 +40,10 @@ public function getGitCommit(): string public function getGitBranch(): string { + // TODO: While the PR source branch is in `bamboo.repository_pr_sourceBranch`, it cannot be reliably + // used, probably because it is environment variables with dot in name. + // As a result, returned branch in case of PR build is the target branch (eg. master) not the PR branch. + return $this->env->getString('bamboo_planRepository_branch'); } diff --git a/src/Ci/Buddy.php b/src/Ci/Buddy.php index b7a40c4..800d4f1 100644 --- a/src/Ci/Buddy.php +++ b/src/Ci/Buddy.php @@ -40,7 +40,13 @@ public function getGitCommit(): string public function getGitBranch(): string { - return $this->env->getString('BUDDY_EXECUTION_BRANCH'); + $prBranch = $this->env->getString('BUDDY_EXECUTION_PULL_REQUEST_HEAD_BRANCH'); + + if ($this->isPullRequest()->no() || empty($prBranch)) { + return $this->env->getString('BUDDY_EXECUTION_BRANCH'); + } + + return $prBranch; } public function getRepositoryName(): string diff --git a/src/Ci/GitHubActions.php b/src/Ci/GitHubActions.php index 35c459e..1609ed0 100644 --- a/src/Ci/GitHubActions.php +++ b/src/Ci/GitHubActions.php @@ -47,9 +47,15 @@ public function getGitCommit(): string public function getGitBranch(): string { - $gitReference = $this->env->getString('GITHUB_REF'); + $prBranch = $this->env->getString('GITHUB_HEAD_REF'); - return preg_replace('~^refs/heads/~', '', $gitReference); + if ($this->isPullRequest()->no() || empty($prBranch)) { + $gitReference = $this->env->getString('GITHUB_REF'); + + return preg_replace('~^refs/heads/~', '', $gitReference); + } + + return $prBranch; } public function getRepositoryName(): string diff --git a/tests/phpt/Ci/CiDetector_AppVeyor.phpt b/tests/phpt/Ci/CiDetector_AppVeyor.phpt index 547ad45..235561e 100644 --- a/tests/phpt/Ci/CiDetector_AppVeyor.phpt +++ b/tests/phpt/Ci/CiDetector_AppVeyor.phpt @@ -2,7 +2,6 @@ AppVeyor: Detect properties --ENV-- -APPVEYOR=True APPVEYOR_ACCOUNT_NAME=OndraM APPVEYOR_API_URL=http://localhost:1563/ APPVEYOR_BUILD_FOLDER=C:\projects\ci-detector @@ -16,16 +15,17 @@ APPVEYOR_PROJECT_ID=321955 APPVEYOR_PROJECT_NAME=ci-detector APPVEYOR_PROJECT_SLUG=ci-detector APPVEYOR_REPO_BRANCH=branchname -APPVEYOR_REPO_COMMIT=11cc783de14cf438a41a60af7cd148a43da74cce -APPVEYOR_REPO_COMMIT_AUTHOR=Ondrej Machulda APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL=ondrej.machulda@gmail.com +APPVEYOR_REPO_COMMIT_AUTHOR=Ondrej Machulda APPVEYOR_REPO_COMMIT_MESSAGE=Foo bar message APPVEYOR_REPO_COMMIT_TIMESTAMP=2017-05-26T14:48:13.0000000Z +APPVEYOR_REPO_COMMIT=11cc783de14cf438a41a60af7cd148a43da74cce APPVEYOR_REPO_NAME=OndraM/ci-detector APPVEYOR_REPO_PROVIDER=gitHub APPVEYOR_REPO_SCM=git APPVEYOR_REPO_TAG=false APPVEYOR_URL=https://ci.appveyor.com +APPVEYOR=True CI=True HOMEDRIVE=C: HOMEPATH=\Users\appveyor @@ -33,8 +33,8 @@ OS=Windows_NT Platform=x64 SystemDrive=C: SystemRoot=C:\Windows -USERDOMAIN=APPVYR-WIN USERDOMAIN_ROAMINGPROFILE=APPVYR-WIN +USERDOMAIN=APPVYR-WIN USERNAME=appveyor windir=C:\Windows diff --git a/tests/phpt/Ci/CiDetector_AppVeyorPullRequest.phpt b/tests/phpt/Ci/CiDetector_AppVeyorPullRequest.phpt index ecf374e..f85e809 100644 --- a/tests/phpt/Ci/CiDetector_AppVeyorPullRequest.phpt +++ b/tests/phpt/Ci/CiDetector_AppVeyorPullRequest.phpt @@ -2,7 +2,6 @@ AppVeyor: Detect properties of PR build --ENV-- -APPVEYOR=True APPVEYOR_ACCOUNT_NAME=OndraM APPVEYOR_API_URL=http://localhost:1563/ APPVEYOR_BUILD_FOLDER=C:\projects\ci-detector @@ -16,21 +15,22 @@ APPVEYOR_PROJECT_ID=321955 APPVEYOR_PROJECT_NAME=ci-detector APPVEYOR_PROJECT_SLUG=ci-detector APPVEYOR_PULL_REQUEST_HEAD_COMMIT=4adb3ce7ab78a1aeec59271f81d15fdec9c3d899 -APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH=repo_name +APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH=feature/pr-branch APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME=foo/ci-detector APPVEYOR_PULL_REQUEST_NUMBER=42 APPVEYOR_PULL_REQUEST_TITLE=Foo bar PR title -APPVEYOR_REPO_BRANCH=branchname -APPVEYOR_REPO_COMMIT=08750c66ed93c27a192d1b6bd5614788f1e5f1e9 -APPVEYOR_REPO_COMMIT_AUTHOR=foo +APPVEYOR_REPO_BRANCH=master APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL=foo@example.com +APPVEYOR_REPO_COMMIT_AUTHOR=foo APPVEYOR_REPO_COMMIT_MESSAGE=Foo bar PR commit message APPVEYOR_REPO_COMMIT_TIMESTAMP=2020-02-11T11:48:29.0000000Z +APPVEYOR_REPO_COMMIT=08750c66ed93c27a192d1b6bd5614788f1e5f1e9 APPVEYOR_REPO_NAME=OndraM/ci-detector APPVEYOR_REPO_PROVIDER=gitHub APPVEYOR_REPO_SCM=git APPVEYOR_REPO_TAG=false APPVEYOR_URL=https://ci.appveyor.com +APPVEYOR=True CI=True HOMEDRIVE=C: HOMEPATH=\Users\appveyor @@ -38,8 +38,8 @@ OS=Windows_NT Platform=x64 SystemDrive=C: SystemRoot=C:\Windows -USERDOMAIN=APPVYR-WIN USERDOMAIN_ROAMINGPROFILE=APPVYR-WIN +USERDOMAIN=APPVYR-WIN USERNAME=appveyor windir=C:\Windows @@ -51,7 +51,11 @@ require __DIR__ . '/../../../vendor/autoload.php'; $ci = (new OndraM\CiDetector\CiDetector())->detect(); echo "Is pull request:\n"; var_dump($ci->isPullRequest()->describe()); +echo "Git branch:\n"; +var_dump($ci->getGitBranch()); --EXPECT-- Is pull request: string(3) "Yes" +Git branch: +string(17) "feature/pr-branch" diff --git a/tests/phpt/Ci/CiDetector_AwsCodeBuild.phpt b/tests/phpt/Ci/CiDetector_AwsCodeBuild.phpt index 35ef888..36ac521 100644 --- a/tests/phpt/Ci/CiDetector_AwsCodeBuild.phpt +++ b/tests/phpt/Ci/CiDetector_AwsCodeBuild.phpt @@ -2,105 +2,50 @@ AWS CodeBuild: Detect properties --ENV-- -NODE_10_VERSION=10.19.0 -ANDROID_SDK_MANAGER_VER=4333796 -MAVEN_DOWNLOAD_SHA512=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0 -MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.maxPerRoute=2 -CODEBUILD_LAST_EXIT=0 -CODEBUILD_START_TIME=1585485986820 -ANT_VERSION=1.10.6 -CODEBUILD_BMR_URL=https://CODEBUILD_AGENT:3000 -NODE_12_VERSION=12.16.1 -JRE_8_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto/jre -DOCKER_BUCKET=download.docker.com -CODEBUILD_SOURCE_VERSION=test/evn -ANDROID_SDK_PLATFORM_TOOLS_28=platforms;android-28 +AWS_ACCOUNT_ID=911074024513 +AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=/v2/credentials/9ab844f8-d292-41ec-b0b9-3895d1901405 +AWS_DEFAULT_OUTPUT=json +AWS_DEFAULT_REGION=eu-west-1 +AWS_ECR_CODEBUILD_URI=911074024513.dkr.ecr.eu-west-1.amazonaws.com/project-api-codebuild +AWS_EXECUTION_ENV=AWS_ECS_EC2 +AWS_REGION=eu-west-1 CODEBUILD_AGENT_ENDPOINT=http://127.0.0.1:7831 -HOSTNAME=202d63ee90d4 +CODEBUILD_AUTH_TOKEN=ce79b1c8-ee3b-4981-bb63-86162d6548b2 +CODEBUILD_BMR_URL=https://CODEBUILD_AGENT:3000 +CODEBUILD_BUILD_ARN=arn:aws:codebuild:eu-west-1:911074024513:build/project-api-pr:449b6959-c0f7-41ac-aac8-7fec365d3004 CODEBUILD_BUILD_ID=project-api-pr:449b6959-c0f7-41ac-aac8-7fec365d3004 -CODEBUILD_KMS_KEY_ID=arn:aws:kms:eu-west-1:911074024513:alias/aws/s3 -JDK_DOWNLOAD_TAR=java-11-amazon-corretto-jdk.tar -POWERSHELL_DOWNLOAD_URL=https://github.com/PowerShell/PowerShell/releases/download/v6.2.1/powershell-6.2.1-linux-x64.tar.gz -PYTHON_PIP_VERSION=19.3.1 -JRE_11_HOME=/opt/jvm/amazon-corretto-11 -SRC_DIR=/usr/src -HOME=/root -OLDPWD=/codebuild/readonly -POWERSHELL_VERSION=6.2.1 -JRE_HOME=/opt/jvm/amazon-corretto-11 -CODEBUILD_GOPATH=/codebuild/output/src341076892 -CODEBUILD_CI=true -GOENV_DISABLE_GOPATH=1 -CODEBUILD_RESOLVED_SOURCE_VERSION=c150e3a3d2d89acd1b1222bf6f7a50b45a4218c0 +CODEBUILD_BUILD_IMAGE=aws/codebuild/standard:4.0 CODEBUILD_BUILD_NUMBER=559 CODEBUILD_BUILD_SUCCEEDING=1 -GRADLE_DOWNLOADS_SHA256=14cd15fc8cc8705bd69dcfa3c8fefb27eb7027f5de4b47a8b279218f76895a91 5.4.1\n336b6898b491f6334502d8074a6b8c2d73ed83b92123106bd4bf837f04111043 4.10.3 -CODEBUILD_BUILD_ARN=arn:aws:codebuild:eu-west-1:911074024513:build/project-api-pr:449b6959-c0f7-41ac-aac8-7fec365d3004 -AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=/v2/credentials/9ab844f8-d292-41ec-b0b9-3895d1901405 -MAVEN_HOME=/opt/maven -AWS_EXECUTION_ENV=AWS_ECS_EC2 -ANT_DOWNLOAD_SHA512=c1a9694c3018e248000ff6f46d48af85f537ef3935e0d5256543c58a240084c0aff5289fd9e94cbc40d5442f3cc43592398047f2548fded40d9882be2b40750d -DOCKER_SHA256=c3c8833e227b61fe6ce0bc5c17f97fa547035bef4ef17cf6601f30b0f20f4ce5 -RUBY_BUILD_SRC_DIR=/usr/local/rbenv/plugins/ruby-build -CODEBUILD_INITIATOR=radim -INSTALLED_GRADLE_VERSIONS=4.10.3 5.4.1 -GRADLE_PATH=/usr/src/gradle -PROJECT_NAME=project-api -DIND_COMMIT=3b5fac462d21ca164b3778647420016315289034 -AWS_DEFAULT_REGION=eu-west-1 -AWS_ECR_CODEBUILD_URI=911074024513.dkr.ecr.eu-west-1.amazonaws.com/project-api-codebuild -PHP_73_VERSION=7.3.13 -ECS_CONTAINER_METADATA_URI=http://169.254.170.2/v3/788d7be3-4280-454e-8f3e-ab9ee035ee04 -PHP_74_VERSION=7.4.1 +CODEBUILD_BUILD_URL=https://eu-west-1.console.aws.amazon.com/codebuild/home?region=eu-west-1#/builds/project-api-pr:449b6959-c0f7-41ac-aac8-7fec365d3004/view/new +CODEBUILD_CI=true +CODEBUILD_CONTAINER_NAME=default CODEBUILD_EXECUTION_ROLE_BUILD= -DOTNET_31_SDK_VERSION=3.1.102 -PATH=/root/.phpenv/shims:/root/.phpenv/bin:/root/.goenv/shims:/root/.goenv/bin:/go/bin:/root/.phpenv/shims:/root/.phpenv/bin:/root/.pyenv/shims:/root/.pyenv/bin:/root/.rbenv/shims:/usr/local/rbenv/bin:/usr/local/rbenv/shims:/root/.dotnet/:/root/.dotnet/tools/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/tools:/usr/local/android-sdk-linux/tools:/usr/local/android-sdk-linux/tools/bin:/usr/local/android-sdk-linux/platform-tools -N_SRC_DIR=/usr/src/n -POWERSHELL_DOWNLOAD_SHA=E8287687C99162BF70FEFCC2E492F3B54F80BE880D86B9A0EC92C71B05C40013 -RUBY_26_VERSION=2.6.5 +CODEBUILD_FE_REPORT_ENDPOINT=https://codebuild.eu-west-1.amazonaws.com/ +CODEBUILD_INITIATOR=radim +CODEBUILD_KMS_KEY_ID=arn:aws:kms:eu-west-1:911074024513:alias/aws/s3 +CODEBUILD_LAST_EXIT=0 CODEBUILD_LOG_PATH=449b6959-c0f7-41ac-aac8-7fec365d3004 -RUBY_27_VERSION=2.7.0 -SBT_VERSION=1.2.8 -ANDROID_SDK_EXTRAS=extras;android;m2repository extras;google;m2repository extras;google;google_play_services -DOCKER_CHANNEL=stable -AWS_DEFAULT_OUTPUT=json -CODEBUILD_BUILD_IMAGE=aws/codebuild/standard:4.0 +CODEBUILD_PROJECT_UUID=83afc255-1a5a-4ded-a73e-105110a67956 +CODEBUILD_RESOLVED_SOURCE_VERSION=c150e3a3d2d89acd1b1222bf6f7a50b45a4218c0 CODEBUILD_SOURCE_REPO_URL=https://github.com/project-app/project-api.git -ANDROID_SDK_MANAGER_SHA256=92ffee5a1d98d856634e8b71132e8a95d96c83a63fde1099be3d86df3106def9 -GITVERSION_VERSION=5.1.2 -ANDROID_SDK_BUILD_TOOLS=build-tools;29.0.2 -AWS_ACCOUNT_ID=911074024513 -DEBIAN_FRONTEND=noninteractive -GOPATH=/go:/codebuild/output/src341076892 -AWS_REGION=eu-west-1 -CODEBUILD_BUILD_URL=https://eu-west-1.console.aws.amazon.com/codebuild/home?region=eu-west-1#/builds/project-api-pr:449b6959-c0f7-41ac-aac8-7fec365d3004/view/new -JAVA_8_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto -GRADLE_VERSION=5.4.1 -DOCKER_VERSION=19.03.3 +CODEBUILD_SOURCE_VERSION=test/evn CODEBUILD_SRC_DIR=/codebuild/output/src341076892/src/github.com/project-app/project-api -CODEBUILD_PROJECT_UUID=83afc255-1a5a-4ded-a73e-105110a67956 -MAVEN_VERSION=3.6.3 -CODEBUILD_AUTH_TOKEN=ce79b1c8-ee3b-4981-bb63-86162d6548b2 -CODEBUILD_CONTAINER_NAME=default -JAVA_11_HOME=/opt/jvm/amazon-corretto-11 -ANDROID_SDK_BUILD_TOOLS_28=build-tools;28.0.3 -JDK_8_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto -JDK_DOWNLOAD_SHA256=4cc9e65e6e3d036b18cfd5fd6c7843d48244e44a60350f7e45036f4825bd3812 -JAVA_HOME=/opt/jvm/amazon-corretto-11 -DOCKER_COMPOSE_VERSION=1.24.0 -PWD=/codebuild/output/src341076892/src/github.com/project-app/project-api -CODEBUILD_FE_REPORT_ENDPOINT=https://codebuild.eu-west-1.amazonaws.com/ -PYTHON_37_VERSION=3.7.6 -ANDROID_HOME=/usr/local/android-sdk-linux -PYTHON_38_VERSION=3.8.1 -GOLANG_12_VERSION=1.12.17 -JDK_11_HOME=/opt/jvm/amazon-corretto-11 -ANDROID_SDK_PLATFORM_TOOLS=platforms;android-29 -RBENV_SRC_DIR=/usr/local/rbenv -GOLANG_13_VERSION=1.13.8 +CODEBUILD_START_TIME=1585485986820 +DEBIAN_FRONTEND=noninteractive +DIND_COMMIT=3b5fac462d21ca164b3778647420016315289034 +DOTNET_31_SDK_VERSION=3.1.102 +ECS_CONTAINER_METADATA_URI=http://169.254.170.2/v3/788d7be3-4280-454e-8f3e-ab9ee035ee04 +GITVERSION_VERSION=5.1.2 +HOME=/root +HOSTNAME=202d63ee90d4 NUGET_XMLDOC_MODE=skip -JDK_HOME=/opt/jvm/amazon-corretto-11 -GOLANG_14_VERSION=1.14.0 +OLDPWD=/codebuild/readonly +PHP_73_VERSION=7.3.13 +PHP_74_VERSION=7.4.1 +PROJECT_NAME=project-api +PWD=/codebuild/output/src341076892/src/github.com/project-app/project-api +SRC_DIR=/usr/src --FILE-- getGitBranch()); Is pull request: string(3) "Yes" Git branch: -string(8) "test/evn" +string(14) "test/pr-branch" diff --git a/tests/phpt/Ci/CiDetector_Bamboo.phpt b/tests/phpt/Ci/CiDetector_Bamboo.phpt index f3983f9..1a35367 100644 --- a/tests/phpt/Ci/CiDetector_Bamboo.phpt +++ b/tests/phpt/Ci/CiDetector_Bamboo.phpt @@ -2,36 +2,36 @@ Bamboo: Detect properties --ENV-- -bamboo_buildResultsUrl=https://bamboo.foo.bar/browse/KEY-FOO-JOB1-3 -bamboo_resultsUrl=https://bamboo.foo.bar/browse/KEY-FOO-JOB1-3 -bamboo_shortPlanName=Plan Name +bamboo_buildKey=KEY-FOO-JOB1 bamboo_buildNumber=3 -bamboo_buildResultKey=KEY-FOO-JOB1-3 bamboo_buildPlanName=Plan Name - Foo Lorem ipsum - Default Job -bamboo_shortJobName=Default Job -bamboo_planName=Plan Name - Foo Lorem ipsum +bamboo_buildResultKey=KEY-FOO-JOB1-3 +bamboo_buildResultsUrl=https://bamboo.foo.bar/browse/KEY-FOO-JOB1-3 +bamboo_buildTimeStamp=2016-07-29T22:48:02.891+02:00 bamboo_planKey=KEY-FOO -bamboo_planRepository_1_revision=3e01b71b3434c0441b24563f1c180bc615f9467d -bamboo_planRepository_1_repositoryUrl=ssh://git@gitserver:7999/project/repo.git -bamboo_planRepository_1_previousRevision=e01b71b3434c0441b24563f1c180bc615f9467d3 +bamboo_planName=Plan Name - Foo Lorem ipsum bamboo_planRepository_1_branch=branch-name bamboo_planRepository_1_name=Repo name -bamboo_repository_2818049_git_repositoryUrl=ssh://git@gitserver:7999/project/repo.git -bamboo_repository_2818049_revision_number=3e01b71b3434c0441b24563f1c180bc615f9467d -bamboo_repository_2818049_previous_revision_number=e01b71b3434c0441b24563f1c180bc615f9467d3 -bamboo_repository_2818049_git_branch=branch-name -bamboo_repository_2818049_name=Repo name -bamboo_repository_2818049_branch_name=branch-name -bamboo_planRepository_revision=3e01b71b3434c0441b24563f1c180bc615f9467d +bamboo_planRepository_1_previousRevision=e01b71b3434c0441b24563f1c180bc615f9467d3 +bamboo_planRepository_1_repositoryUrl=ssh://git@gitserver:7999/project/repo.git +bamboo_planRepository_1_revision=3e01b71b3434c0441b24563f1c180bc615f9467d +bamboo_planRepository_branch=branch-name +bamboo_planRepository_branchName=branch-name +bamboo_planRepository_name=Repo name bamboo_planRepository_previousRevision=e01b71b3434c0441b24563f1c180bc615f9467d3 bamboo_planRepository_repositoryUrl=ssh://git@gitserver:7999/project/repo.git -bamboo_planRepository_name=Repo name -bamboo_planRepository_branchName=branch-name -bamboo_planRepository_branch=branch-name -bamboo_buildTimeStamp=2016-07-29T22:48:02.891+02:00 -bamboo_shortPlanKey=foo -bamboo_buildKey=KEY-FOO-JOB1 +bamboo_planRepository_revision=3e01b71b3434c0441b24563f1c180bc615f9467d +bamboo_repository_2818049_branch_name=branch-name +bamboo_repository_2818049_git_branch=branch-name +bamboo_repository_2818049_git_repositoryUrl=ssh://git@gitserver:7999/project/repo.git +bamboo_repository_2818049_name=Repo name +bamboo_repository_2818049_previous_revision_number=e01b71b3434c0441b24563f1c180bc615f9467d3 +bamboo_repository_2818049_revision_number=3e01b71b3434c0441b24563f1c180bc615f9467d +bamboo_resultsUrl=https://bamboo.foo.bar/browse/KEY-FOO-JOB1-3 bamboo_shortJobKey=JOB1 +bamboo_shortJobName=Default Job +bamboo_shortPlanKey=foo +bamboo_shortPlanName=Plan Name --FILE-- detect(); echo "Is pull request:\n"; var_dump($ci->isPullRequest()->describe()); +echo "Git branch:\n"; +var_dump($ci->getGitBranch()); --EXPECT-- Is pull request: string(3) "Yes" +Git branch: +string(11) "branch-name" diff --git a/tests/phpt/Ci/CiDetector_Buddy.phpt b/tests/phpt/Ci/CiDetector_Buddy.phpt index dcb270e..f5f61ce 100644 --- a/tests/phpt/Ci/CiDetector_Buddy.phpt +++ b/tests/phpt/Ci/CiDetector_Buddy.phpt @@ -2,47 +2,47 @@ Buddy: Detect properties --ENV-- -BUDDY=true -BUDDY_INVOKER_ID=1 -BUDDY_PIPELINE_TRIGGER_MODE=MANUAL -BUDDY_EXECUTION_REVISION_URL=https://app.buddy.works/myworkspace/my-project/repository/commit/e5e13f8b7f8d5c6096a0501dc09b48eef05fea96 +BUDDY_EXECUTION_BRANCH=master +BUDDY_EXECUTION_CHANGELOG=[e5e13f8] Create buddy.yml | mikebenson | 2019-01-01T07:14:58 BUDDY_EXECUTION_CLEAR_CACHE=false -BUDDY_PIPELINE_REF_NAME=master -BUDDY_EXECUTION_REVISION_SHORT=e5e13f8 -BUDDY_EXECUTION_REVISION_COMMITTER_EMAIL=mikebenson@buddy.works -BUDDY_WORKSPACE_ID=1 -BUDDY_PROJECT_NAME=my-project -BUDDY_INVOKER_NAME=Mike Benson -BUDDY_PIPELINE_ID=1 BUDDY_EXECUTION_COMMENT=My first execution -BUDDY_PIPELINE_TARGET_SITE_URL=https://buddy.works/ -BUDDY_EXECUTION_BRANCH=master -BUDDY_PROJECT_URL=https://app.buddy.works/myworkspace/my-project -BUDDY_SCM_URL=https://github.com/buddyworks/my-project -BUDDY_EXECUTION_REVISION=e5e13f8b7f8d5c6096a0501dc09b48eef05fea96 BUDDY_EXECUTION_ID=1 -BUDDY_WORKSPACE_URL=https://app.buddy.works/myworkspace -BUDDY_INVOKER_EMAIL=mikebenson@buddy.works -BUDDY_PIPELINE_URL=https://app.buddy.works/myworkspace/my-project/pipelines/pipeline/1 +BUDDY_EXECUTION_MODE=MANUAL +BUDDY_EXECUTION_REFRESH=false +BUDDY_EXECUTION_REVISION_COMMITTER_EMAIL=mikebenson@buddy.works +BUDDY_EXECUTION_REVISION_COMMITTER_NAME=Mike Benson +BUDDY_EXECUTION_REVISION_MESSAGE=Create buddy.yml +BUDDY_EXECUTION_REVISION_SHORT=e5e13f8 BUDDY_EXECUTION_REVISION_SUBJECT=Create buddy.yml +BUDDY_EXECUTION_REVISION_URL=https://app.buddy.works/myworkspace/my-project/repository/commit/e5e13f8b7f8d5c6096a0501dc09b48eef05fea96 +BUDDY_EXECUTION_REVISION=e5e13f8b7f8d5c6096a0501dc09b48eef05fea96 +BUDDY_EXECUTION_START_DATE=2019-01-01T11:27:40.140Z +BUDDY_EXECUTION_TAG=v1.0 +BUDDY_EXECUTION_URL=https://app.buddy.works/myworkspace/my-project/pipelines/pipeline/1/execution/5d9dc42c422f5a268b389d08 +BUDDY_FAILED_ACTION_NAME=Upload files +BUDDY_INVOKER_AVATAR_URL=https://app.buddy.works/image-server/user/0/0/0/0/0/0/1/05d20f3d58ce09a3b4e9g3334a810603/w/32/32/AVATAR.png +BUDDY_INVOKER_EMAIL=mikebenson@buddy.works +BUDDY_INVOKER_ID=1 +BUDDY_INVOKER_NAME=Mike Benson BUDDY_INVOKER_URL=https://app.buddy.works/myworkspace/profile/1 -BUDDY_SCM_PROVIDER=GITHUB +BUDDY_PIPELINE_ID=1 BUDDY_PIPELINE_NAME=Deploy to Production -BUDDY_EXECUTION_REVISION_COMMITTER_NAME=Mike Benson -BUDDY_REPO_SSH_URL=git@github.com:buddyworks/my-project -BUDDY_EXECUTION_REFRESH=false -BUDDY_EXECUTION_REVISION_MESSAGE=Create buddy.yml +BUDDY_PIPELINE_REF_NAME=master +BUDDY_PIPELINE_TARGET_SITE_URL=https://buddy.works/ +BUDDY_PIPELINE_TRIGGER_MODE=MANUAL +BUDDY_PIPELINE_URL=https://app.buddy.works/myworkspace/my-project/pipelines/pipeline/1 BUDDY_PROJECT_NAME_ID=my-project -BUDDY_WORKSPACE_DOMAIN=myworkspace +BUDDY_PROJECT_NAME=my-project +BUDDY_PROJECT_URL=https://app.buddy.works/myworkspace/my-project BUDDY_REPO_SLUG=buddyworks/my-project -BUDDY_EXECUTION_START_DATE=2019-01-01T11:27:40.140Z -BUDDY_EXECUTION_CHANGELOG=[e5e13f8] Create buddy.yml | mikebenson | 2019-01-01T07:14:58 -BUDDY_EXECUTION_URL=https://app.buddy.works/myworkspace/my-project/pipelines/pipeline/1/execution/5d9dc42c422f5a268b389d08 -BUDDY_EXECUTION_MODE=MANUAL +BUDDY_REPO_SSH_URL=git@github.com:buddyworks/my-project +BUDDY_SCM_PROVIDER=GITHUB +BUDDY_SCM_URL=https://github.com/buddyworks/my-project +BUDDY_WORKSPACE_DOMAIN=myworkspace +BUDDY_WORKSPACE_ID=1 BUDDY_WORKSPACE_NAME=My Workspace -BUDDY_INVOKER_AVATAR_URL=https://app.buddy.works/image-server/user/0/0/0/0/0/0/1/05d20f3d58ce09a3b4e9g3334a810603/w/32/32/AVATAR.png -BUDDY_EXECUTION_TAG=v1.0 -BUDDY_FAILED_ACTION_NAME=Upload files +BUDDY_WORKSPACE_URL=https://app.buddy.works/myworkspace +BUDDY=true --FILE-- detect(); echo "Is pull request:\n"; var_dump($ci->isPullRequest()->describe()); +echo "Git branch:\n"; +var_dump($ci->getGitBranch()); --EXPECT-- Is pull request: string(3) "Yes" +Git branch: +string(17) "feature/pr-branch" diff --git a/tests/phpt/Ci/CiDetector_Circle.phpt b/tests/phpt/Ci/CiDetector_Circle.phpt index 7129b12..e0ec5ab 100644 --- a/tests/phpt/Ci/CiDetector_Circle.phpt +++ b/tests/phpt/Ci/CiDetector_Circle.phpt @@ -2,26 +2,26 @@ Circle CI: Detect properties --ENV-- -CIRCLE_BUILD_NUM=1337 -CIRCLE_NODE_TOTAL=1 -CIRCLE_ARTIFACTS=/tmp/circle-artifacts.UZ1pVXp -CI_PULL_REQUESTS= -CIRCLE_PROJECT_USERNAME=OndraM -CIRCLE_NODE_INDEX=0 -CIRCLE_COMPARE_URL=https://github.com/OndraM/ci-detector/compare/dd26fa7b1c1e...fad3f7bdbf35 -CIRCLE_BRANCH=test-circleci CI_PULL_REQUEST= -CIRCLE_USERNAME=OndraM -CIRCLE_PREVIOUS_BUILD_NUM=1336 +CI_PULL_REQUESTS= CI_REPORTS=/tmp/circle-junit.gBW8B4r -CIRCLE_BUILD_URL=https://circleci.com/gh/OndraM/ci-detector/1337 -CIRCLECI=true -CIRCLE_BUILD_IMAGE=ubuntu-12.04 -CIRCLE_SHA1=fad3f7bdbf3515d1e9285b8aa80feeff74507bdd CI=true +CIRCLE_ARTIFACTS=/tmp/circle-artifacts.UZ1pVXp +CIRCLE_BRANCH=test-circleci +CIRCLE_BUILD_IMAGE=ubuntu-12.04 +CIRCLE_BUILD_NUM=1337 +CIRCLE_BUILD_URL=https://circleci.com/gh/OndraM/ci-detector/1337 +CIRCLE_COMPARE_URL=https://github.com/OndraM/ci-detector/compare/dd26fa7b1c1e...fad3f7bdbf35 +CIRCLE_NODE_INDEX=0 +CIRCLE_NODE_TOTAL=1 +CIRCLE_PREVIOUS_BUILD_NUM=1336 +CIRCLE_PROJECT_REPONAME=ci-detector +CIRCLE_PROJECT_USERNAME=OndraM CIRCLE_REPOSITORY_URL=https://github.com/OndraM/ci-detector +CIRCLE_SHA1=fad3f7bdbf3515d1e9285b8aa80feeff74507bdd CIRCLE_TEST_REPORTS=/tmp/circle-junit.gBW8B4r -CIRCLE_PROJECT_REPONAME=ci-detector +CIRCLE_USERNAME=OndraM +CIRCLECI=true --FILE-- detect(); echo "Is pull request:\n"; var_dump($ci->isPullRequest()->describe()); +echo "Git branch:\n"; +var_dump($ci->getGitBranch()); --EXPECT-- Is pull request: string(3) "Yes" +Git branch: +string(13) "test-circleci" diff --git a/tests/phpt/Ci/CiDetector_Codeship.phpt b/tests/phpt/Ci/CiDetector_Codeship.phpt index 3e276e6..30020a6 100644 --- a/tests/phpt/Ci/CiDetector_Codeship.phpt +++ b/tests/phpt/Ci/CiDetector_Codeship.phpt @@ -2,22 +2,22 @@ Codeship: Detect properties --ENV-- +CI_BRANCH=test-codeship +CI_BUILD_NUMBER=17594878 +CI_BUILD_URL=https://codeship.com/projects/169447/builds/17594878 CI_COMMIT_ID=26e646685c1e625939f6b2de0e5f30b59cc34d60 -CODESHIP=TRUE +CI_COMMITTER_EMAIL=ondrej.machulda@gmail.com CI_COMMITTER_NAME=Ondej Machulda -COMMIT_ID=26e646685c1e625939f6b2de0e5f30b59cc34d60 +CI_COMMITTER_USERNAME=OndraM +CI_MESSAGE=Add support for Codeship +CI_NAME=codeship CI_PULL_REQUEST=false CI_REPO_NAME=OndraM/ci-detector -CI_COMMITTER_USERNAME=OndraM -CI_COMMITTER_EMAIL=ondrej.machulda@gmail.com +CI=true +CODESHIP=TRUE +COMMIT_ID=26e646685c1e625939f6b2de0e5f30b59cc34d60 PARALLEL_TEST_PROCESSORS=4 RAILSONFIRE=TRUE -CI_NAME=codeship -CI_BRANCH=test-codeship -CI=true -CI_MESSAGE=Add support for Codeship -CI_BUILD_URL=https://codeship.com/projects/169447/builds/17594878 -CI_BUILD_NUMBER=17594878 --FILE-- detect(); echo "Is pull request:\n"; var_dump($ci->isPullRequest()->describe()); +echo "Git branch:\n"; +var_dump($ci->getGitBranch()); --EXPECT-- Is pull request: string(3) "Yes" +Git branch: +string(13) "test-codeship" diff --git a/tests/phpt/Ci/CiDetector_Continuousphp.phpt b/tests/phpt/Ci/CiDetector_Continuousphp.phpt index 9ef5e9c..0ac1121 100644 --- a/tests/phpt/Ci/CiDetector_Continuousphp.phpt +++ b/tests/phpt/Ci/CiDetector_Continuousphp.phpt @@ -2,45 +2,45 @@ Continuousphp CI: Detect properties --ENV-- +_=/usr/bin/env +CONTINUOUSPHP=continuousphp +CPHP_BUILD_ID=31b581f1-95bf-4d09-b458-8d0da757bc8d +CPHP_BUILT_BY=OndraM +CPHP_GIT_COMMIT=87bf5720b148a6fee6c8e70888800a4360a13e08 CPHP_GIT_REF=refs/heads/test-continuousphp-branch -NVM_CD_FLAGS= -PHPBREW_PATH=/home/cphp/.phpbrew/php/php-7.1.0/bin -PHPBREW_BIN=/home/cphp/.phpbrew/bin -SHELL=/bin/bash -SSH_CLIENT=172.18.0.1 39008 22 -PHPBREW_ROOT=/home/cphp/.phpbrew CPHP_PR_ID= -LC_ALL=en_US.UTF-8 -NVM_DIR=/usr/local/src/nvm -USER=cphp -PHPBREW_SET_PROMPT=1 +CPHP_TOKEN= GIT_SSH=/usr/bin/git_ssh.sh -RBENV_ROOT=/opt/rbenv -MAIL=/var/mail/cphp -PHPBREW_HOME=/home/cphp/.phpbrew -PHPBREW_VERSION_REGEX=^([[:digit:]]+\.){2}[[:digit:]]+((alpha|beta|RC)[[:digit:]]+)?$ -PWD=/home/cphp/data/container/31b581f1-95bf-4d09-b458-8d0da757bc8d/workspace +GITHUB_TOKEN= +HOME=/home/cphp JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 -CPHP_TOKEN= -PHPBREW_LOOKUP_PREFIX= LANG=en_US.UTF-8 +LANGUAGE=en_US.UTF-8 +LC_ALL=en_US.UTF-8 +LOGNAME=cphp +MAIL=/var/mail/cphp +NVM_BIN=/usr/local/src/nvm/versions/node/v6.9.2/bin +NVM_CD_FLAGS= +NVM_DIR=/usr/local/src/nvm +OLDPWD=/home/cphp PATH_WITHOUT_PHPBREW=/usr/local/src/nvm/versions/node/v6.9.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games +PHPBREW_BIN=/home/cphp/.phpbrew/bin +PHPBREW_HOME=/home/cphp/.phpbrew +PHPBREW_LOOKUP_PREFIX= +PHPBREW_PATH=/home/cphp/.phpbrew/php/php-7.1.0/bin +PHPBREW_PHP=php-7.1.0 +PHPBREW_ROOT=/home/cphp/.phpbrew +PHPBREW_SET_PROMPT=1 +PHPBREW_VERSION_REGEX=^([[:digit:]]+\.){2}[[:digit:]]+((alpha|beta|RC)[[:digit:]]+)?$ PS1=\w > \u@\h [$(phpbrew_current_php_version)]\n\$ -CPHP_BUILT_BY=OndraM +PWD=/home/cphp/data/container/31b581f1-95bf-4d09-b458-8d0da757bc8d/workspace +RBENV_ROOT=/opt/rbenv RBENV_SHELL=bash +SHELL=/bin/bash SHLVL=1 -HOME=/home/cphp -LANGUAGE=en_US.UTF-8 -CONTINUOUSPHP=continuousphp -LOGNAME=cphp -CPHP_BUILD_ID=31b581f1-95bf-4d09-b458-8d0da757bc8d +SSH_CLIENT=172.18.0.1 39008 22 SSH_CONNECTION=172.18.0.1 39008 172.18.0.2 22 -NVM_BIN=/usr/local/src/nvm/versions/node/v6.9.2/bin -GITHUB_TOKEN= -CPHP_GIT_COMMIT=87bf5720b148a6fee6c8e70888800a4360a13e08 -PHPBREW_PHP=php-7.1.0 -_=/usr/bin/env -OLDPWD=/home/cphp +USER=cphp --FILE-- GIT_SSH=/usr/bin/git_ssh.sh -RBENV_ROOT=/opt/rbenv -MAIL=/var/mail/cphp -PHPBREW_HOME=/home/cphp/.phpbrew -PHPBREW_VERSION_REGEX=^([[:digit:]]+\.){2}[[:digit:]]+((alpha|beta|RC)[[:digit:]]+)?$ -PWD=/home/cphp/data/container/31b581f1-95bf-4d09-b458-8d0da757bc8d/workspace +GITHUB_TOKEN= +HOME=/home/cphp JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 -CPHP_TOKEN= -PHPBREW_LOOKUP_PREFIX= LANG=en_US.UTF-8 +LANGUAGE=en_US.UTF-8 +LC_ALL=en_US.UTF-8 +LOGNAME=cphp +MAIL=/var/mail/cphp +NVM_BIN=/usr/local/src/nvm/versions/node/v6.9.2/bin +NVM_CD_FLAGS= +NVM_DIR=/usr/local/src/nvm +OLDPWD=/home/cphp PATH_WITHOUT_PHPBREW=/usr/local/src/nvm/versions/node/v6.9.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games +PHPBREW_BIN=/home/cphp/.phpbrew/bin +PHPBREW_HOME=/home/cphp/.phpbrew +PHPBREW_LOOKUP_PREFIX= +PHPBREW_PATH=/home/cphp/.phpbrew/php/php-7.1.0/bin +PHPBREW_PHP=php-7.1.0 +PHPBREW_ROOT=/home/cphp/.phpbrew +PHPBREW_SET_PROMPT=1 +PHPBREW_VERSION_REGEX=^([[:digit:]]+\.){2}[[:digit:]]+((alpha|beta|RC)[[:digit:]]+)?$ PS1=\w > \u@\h [$(phpbrew_current_php_version)]\n\$ -CPHP_BUILT_BY=OndraM +PWD=/home/cphp/data/container/31b581f1-95bf-4d09-b458-8d0da757bc8d/workspace +RBENV_ROOT=/opt/rbenv RBENV_SHELL=bash +SHELL=/bin/bash SHLVL=1 -HOME=/home/cphp -LANGUAGE=en_US.UTF-8 -CONTINUOUSPHP=continuousphp -LOGNAME=cphp -CPHP_BUILD_ID=31b581f1-95bf-4d09-b458-8d0da757bc8d +SSH_CLIENT=172.18.0.1 39008 22 SSH_CONNECTION=172.18.0.1 39008 172.18.0.2 22 -NVM_BIN=/usr/local/src/nvm/versions/node/v6.9.2/bin -GITHUB_TOKEN= -CPHP_GIT_COMMIT=87bf5720b148a6fee6c8e70888800a4360a13e08 -PHPBREW_PHP=php-7.1.0 -_=/usr/bin/env -OLDPWD=/home/cphp +USER=cphp --FILE-- detect(); echo "Is pull request:\n"; var_dump($ci->isPullRequest()->describe()); +echo "Git branch:\n"; +var_dump($ci->getGitBranch()); --EXPECT-- Is pull request: string(3) "Yes" +Git branch: +string(25) "test-continuousphp-branch" diff --git a/tests/phpt/Ci/CiDetector_Drone.phpt b/tests/phpt/Ci/CiDetector_Drone.phpt index 0e6aa3f..124ea44 100644 --- a/tests/phpt/Ci/CiDetector_Drone.phpt +++ b/tests/phpt/Ci/CiDetector_Drone.phpt @@ -2,84 +2,84 @@ Drone CI: Detect properties --ENV-- -DRONE_COMMIT_AUTHOR_AVATAR=https://avatars0.githubusercontent.com/u/793041?v=4 -DRONE_BRANCH=test-drone -DRONE_JOB_FINISHED=1510195883 -CI=drone -HOSTNAME=641fabf80a16 -DRONE_COMMIT_AUTHOR=OndraM -DRONE_REPO_LINK=https://github.com/OndraM/ci-detector -CI_BUILD_STARTED=1510195880 -CI_BUILD_NUMBER=2 -PHP_INI_DIR=/usr/local/etc/php -CI_WORKSPACE=/drone/src/github.com/OndraM/ci-detector/commit/3986f34176d2a641fc11bc41a3875c67bdc46aa5 -CI_SYSTEM_LINK=http://drone.local -CI_BUILD_LINK=https://github.com/OndraM/ci-detector/commit/3986f34176d2a641fc11bc41a3875c67bdc46aa5 -SHLVL=2 -HOME=/root -DRONE_COMMIT_BRANCH=test-drone -DRONE_REPO_SCM=git -DRONE_BUILD_STATUS=success -PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie +CI_BUILD_CREATED=1510195880 CI_BUILD_EVENT=push +CI_BUILD_FINISHED=1510195883 +CI_BUILD_LINK=https://github.com/OndraM/ci-detector/commit/3986f34176d2a641fc11bc41a3875c67bdc46aa5 +CI_BUILD_NUMBER=2 +CI_BUILD_STARTED=1510195880 +CI_BUILD_STATUS=success +CI_COMMIT_AUTHOR_AVATAR=https://avatars0.githubusercontent.com/u/793041?v=4 +CI_COMMIT_AUTHOR_EMAIL=ondrej.machulda@gmail.com +CI_COMMIT_AUTHOR_NAME=OndraM +CI_COMMIT_AUTHOR=OndraM +CI_COMMIT_BRANCH=test-drone +CI_COMMIT_MESSAGE=Test Drone CI build +CI_COMMIT_REF=refs/heads/test-drone +CI_COMMIT_SHA=3986f34176d2a641fc11bc41a3875c67bdc46aa5 +CI_JOB_FINISHED=1510195883 CI_JOB_NUMBER=1 CI_JOB_STARTED=1510195880 -PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -PHP_MD5= +CI_JOB_STATUS=success +CI_REMOTE_URL=https://github.com/OndraM/ci-detector.git +CI_REPO_LINK=https://github.com/OndraM/ci-detector CI_REPO_NAME=OndraM/ci-detector -CI_BUILD_CREATED=1510195880 +CI_REPO_REMOTE=https://github.com/OndraM/ci-detector.git +CI_REPO=OndraM/ci-detector +CI_SYSTEM_ARCH=linux/amd64 +CI_SYSTEM_LINK=http://drone.local +CI_SYSTEM_NAME=drone +CI_SYSTEM=drone +CI_WORKSPACE=/drone/src/github.com/OndraM/ci-detector/commit/3986f34176d2a641fc11bc41a3875c67bdc46aa5 +CI=drone DRONE_ARCH=linux/amd64 -CI_COMMIT_SHA=3986f34176d2a641fc11bc41a3875c67bdc46aa5 -CI_COMMIT_AUTHOR_EMAIL=ondrej.machulda@gmail.com -PHP_VERSION=7.1.10 -CI_COMMIT_REF=refs/heads/test-drone -GPG_KEYS=A917B1ECDA84AEC2B568FED6F50ABC807BD5DCD0 528995BFEDFBA7191D46839EF9BA0ADA31CBD89E -DRONE_REPO_BRANCH=test-drone +DRONE_BRANCH=test-drone +DRONE_BUILD_CREATED=1510195880 +DRONE_BUILD_EVENT=push +DRONE_BUILD_FINISHED=1510195883 +DRONE_BUILD_LINK=http://drone.local/OndraM/ci-detector/2 +DRONE_BUILD_NUMBER=2 +DRONE_BUILD_STARTED=1510195880 +DRONE_BUILD_STATUS=success +DRONE_COMMIT_AUTHOR_AVATAR=https://avatars0.githubusercontent.com/u/793041?v=4 +DRONE_COMMIT_AUTHOR_EMAIL=ondrej.machulda@gmail.com +DRONE_COMMIT_AUTHOR=OndraM +DRONE_COMMIT_BRANCH=test-drone +DRONE_COMMIT_LINK=https://github.com/OndraM/ci-detector/commit/3986f34176d2a641fc11bc41a3875c67bdc46aa5 DRONE_COMMIT_MESSAGE=Test Drone CI build -PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -PHP_ASC_URL=https://secure.php.net/get/php-7.1.10.tar.xz.asc/from/this/mirror -CI_BUILD_FINISHED=1510195883 +DRONE_COMMIT_REF=refs/heads/test-drone +DRONE_COMMIT_SHA=3986f34176d2a641fc11bc41a3875c67bdc46aa5 +DRONE_COMMIT=3986f34176d2a641fc11bc41a3875c67bdc46aa5 +DRONE_JOB_FINISHED=1510195883 +DRONE_JOB_NUMBER=1 +DRONE_JOB_STARTED=1510195880 DRONE_JOB_STATUS=success DRONE_REMOTE_URL=https://github.com/OndraM/ci-detector.git -PHP_URL=https://secure.php.net/get/php-7.1.10.tar.xz/from/this/mirror -CI_REPO=OndraM/ci-detector +DRONE_REPO_BRANCH=test-drone +DRONE_REPO_LINK=https://github.com/OndraM/ci-detector +DRONE_REPO_NAME=ci-detector DRONE_REPO_OWNER=OndraM -CI_COMMIT_AUTHOR_NAME=OndraM -CI_COMMIT_AUTHOR_AVATAR=https://avatars0.githubusercontent.com/u/793041?v=4 +DRONE_REPO_SCM=git +DRONE_REPO=OndraM/ci-detector +DRONE_WORKSPACE=/drone/src/github.com/OndraM/ci-detector/commit/3986f34176d2a641fc11bc41a3875c67bdc46aa5 DRONE=true +GPG_KEYS=A917B1ECDA84AEC2B568FED6F50ABC807BD5DCD0 528995BFEDFBA7191D46839EF9BA0ADA31CBD89E +HOME=/root +HOSTNAME=641fabf80a16 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -DRONE_BUILD_STARTED=1510195880 -DRONE_BUILD_NUMBER=2 -CI_JOB_FINISHED=1510195883 -DRONE_BUILD_LINK=http://drone.local/OndraM/ci-detector/2 -DRONE_WORKSPACE=/drone/src/github.com/OndraM/ci-detector/commit/3986f34176d2a641fc11bc41a3875c67bdc46aa5 -CI_COMMIT_AUTHOR=OndraM -CI_REPO_LINK=https://github.com/OndraM/ci-detector -CI_REPO_REMOTE=https://github.com/OndraM/ci-detector.git -CI_COMMIT_BRANCH=test-drone -DRONE_COMMIT=3986f34176d2a641fc11bc41a3875c67bdc46aa5 -SHELL=/bin/sh -CI_SYSTEM_ARCH=linux/amd64 -DRONE_JOB_NUMBER=1 -DRONE_JOB_STARTED=1510195880 -DRONE_BUILD_EVENT=push -DRONE_COMMIT_AUTHOR_EMAIL=ondrej.machulda@gmail.com -DRONE_REPO_NAME=ci-detector -DRONE_BUILD_CREATED=1510195880 -DRONE_COMMIT_SHA=3986f34176d2a641fc11bc41a3875c67bdc46aa5 -CI_BUILD_STATUS=success -CI_SYSTEM_NAME=drone -DRONE_COMMIT_REF=refs/heads/test-drone +PHP_ASC_URL=https://secure.php.net/get/php-7.1.10.tar.xz.asc/from/this/mirror +PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 +PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 +PHP_INI_DIR=/usr/local/etc/php +PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie +PHP_MD5= +PHP_SHA256=2b8efa771a2ead0bb3ae67b530ca505b5b286adc873cca9ce97a6e1d6815c50b +PHP_URL=https://secure.php.net/get/php-7.1.10.tar.xz/from/this/mirror +PHP_VERSION=7.1.10 PHPIZE_DEPS=autoconf dpkg-dev dpkg file g++ gcc libc-dev make pcre-dev pkgconf re2c PWD=/drone/src/github.com/OndraM/ci-detector/commit/3986f34176d2a641fc11bc41a3875c67bdc46aa5 -DRONE_COMMIT_LINK=https://github.com/OndraM/ci-detector/commit/3986f34176d2a641fc11bc41a3875c67bdc46aa5 -DRONE_BUILD_FINISHED=1510195883 -PHP_SHA256=2b8efa771a2ead0bb3ae67b530ca505b5b286adc873cca9ce97a6e1d6815c50b -DRONE_REPO=OndraM/ci-detector -CI_COMMIT_MESSAGE=Test Drone CI build -CI_SYSTEM=drone -CI_REMOTE_URL=https://github.com/OndraM/ci-detector.git -CI_JOB_STATUS=success +SHELL=/bin/sh +SHLVL=2 --FILE-- detect(); echo "Is pull request:\n"; var_dump($ci->isPullRequest()->describe()); +echo "Git branch:\n"; +var_dump($ci->getGitBranch()); --EXPECT-- Is pull request: string(3) "Yes" +Git branch: +string(10) "test-drone" diff --git a/tests/phpt/Ci/CiDetector_GitHubActions.phpt b/tests/phpt/Ci/CiDetector_GitHubActions.phpt index 3b03813..4c3c70b 100644 --- a/tests/phpt/Ci/CiDetector_GitHubActions.phpt +++ b/tests/phpt/Ci/CiDetector_GitHubActions.phpt @@ -2,60 +2,60 @@ GitHub Actions: Detect properties --ENV-- -LEIN_HOME=/usr/local/lib/lein -M2_HOME=/usr/share/apache-maven-3.6.2 -BOOST_ROOT=/usr/local/share/boost/1.69.0 -GOROOT_1_11_X64=/usr/local/go1.11 -ANDROID_HOME=/usr/local/lib/android/sdk -JAVA_HOME_11_X64=/usr/lib/jvm/zulu-11-azure-amd64 -ImageVersion=20191209.1 +_=/usr/bin/env AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache -LANG=C.UTF-8 -INVOCATION_ID=0da474cddda344058bd754b447c0a48f -JAVA_HOME_12_X64=/usr/lib/jvm/zulu-12-azure-amd64 +ANDROID_HOME=/usr/local/lib/android/sdk ANDROID_SDK_ROOT=/usr/local/lib/android/sdk -RUNNER_TOOL_CACHE=/opt/hostedtoolcache -JAVA_HOME=/usr/lib/jvm/zulu-8-azure-amd64 -RUNNER_TRACKING_ID=github_f681674d-e8eb-47f7-9fcb-0aee53e58da1 -GITHUB_ACTIONS=true +ANT_HOME=/usr/share/ant +BOOST_ROOT_1_69_0=/usr/local/share/boost/1.69.0 +BOOST_ROOT=/usr/local/share/boost/1.69.0 +CHROME_BIN=/usr/bin/google-chrome +CONDA=/usr/share/miniconda +DEPLOYMENT_BASEPATH=/opt/runner DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 -USER=runner -GITHUB_HEAD_REF= -GITHUB_ACTOR=OndraM GITHUB_ACTION=run333 -GRADLE_HOME=/usr/share/gradle -PWD=/home/runner/work/ci-detector/ci-detector -HOME=/home/runner -GOROOT=/usr/local/go1.12 -JOURNAL_STREAM=9:28471 -JAVA_HOME_8_X64=/usr/lib/jvm/zulu-8-azure-amd64 -RUNNER_TEMP=/home/runner/work/_temp -CONDA=/usr/share/miniconda -GOROOT_1_13_X64=/usr/local/go1.13 -BOOST_ROOT_1_69_0=/usr/local/share/boost/1.69.0 -RUNNER_WORKSPACE=/home/runner/work/ci-detector +GITHUB_ACTIONS=true +GITHUB_ACTOR=OndraM +GITHUB_BASE_REF= +GITHUB_EVENT_NAME=push +GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json +GITHUB_HEAD_REF= GITHUB_REF=refs/heads/test-github +GITHUB_REPOSITORY=OndraM/ci-detector GITHUB_SHA=e24a68b0ac3f9d1afe29901943e94df2bf41c932 +GITHUB_WORKFLOW=PHP +GITHUB_WORKSPACE=/home/runner/work/ci-detector/ci-detector +GOROOT_1_11_X64=/usr/local/go1.11 GOROOT_1_12_X64=/usr/local/go1.12 -DEPLOYMENT_BASEPATH=/opt/runner -GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json -RUNNER_OS=Linux -GITHUB_BASE_REF= -VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg -PERFLOG_LOCATION_SETTING=RUNNER_PERFLOG +GOROOT_1_13_X64=/usr/local/go1.13 +GOROOT=/usr/local/go1.12 +GRADLE_HOME=/usr/share/gradle +HOME=/home/runner +ImageVersion=20191209.1 +INVOCATION_ID=0da474cddda344058bd754b447c0a48f +JAVA_HOME_11_X64=/usr/lib/jvm/zulu-11-azure-amd64 +JAVA_HOME_12_X64=/usr/lib/jvm/zulu-12-azure-amd64 JAVA_HOME_7_X64=/usr/lib/jvm/zulu-7-azure-amd64 -RUNNER_USER=runner -SHLVL=1 -GITHUB_REPOSITORY=OndraM/ci-detector -GITHUB_EVENT_NAME=push +JAVA_HOME_8_X64=/usr/lib/jvm/zulu-8-azure-amd64 +JAVA_HOME=/usr/lib/jvm/zulu-8-azure-amd64 +JOURNAL_STREAM=9:28471 +LANG=C.UTF-8 +LEIN_HOME=/usr/local/lib/lein LEIN_JAR=/usr/local/lib/lein/self-installs/leiningen-2.9.1-standalone.jar -RUNNER_PERFLOG=/home/runner/perflog -GITHUB_WORKFLOW=PHP -ANT_HOME=/usr/share/ant +M2_HOME=/usr/share/apache-maven-3.6.2 PATH=/usr/share/rust/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin -GITHUB_WORKSPACE=/home/runner/work/ci-detector/ci-detector -CHROME_BIN=/usr/bin/google-chrome -_=/usr/bin/env +PERFLOG_LOCATION_SETTING=RUNNER_PERFLOG +PWD=/home/runner/work/ci-detector/ci-detector +RUNNER_OS=Linux +RUNNER_PERFLOG=/home/runner/perflog +RUNNER_TEMP=/home/runner/work/_temp +RUNNER_TOOL_CACHE=/opt/hostedtoolcache +RUNNER_TRACKING_ID=github_f681674d-e8eb-47f7-9fcb-0aee53e58da1 +RUNNER_USER=runner +RUNNER_WORKSPACE=/home/runner/work/ci-detector +SHLVL=1 +USER=runner +VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg --FILE-- detect(); echo "Is pull request:\n"; var_dump($ci->isPullRequest()->describe()); +echo "Git branch:\n"; +var_dump($ci->getGitBranch()); --EXPECT-- Is pull request: string(3) "Yes" +Git branch: +string(17) "feature/pr-branch" diff --git a/tests/phpt/Ci/CiDetector_GitLab.phpt b/tests/phpt/Ci/CiDetector_GitLab.phpt index 0fc4cab..56ca724 100644 --- a/tests/phpt/Ci/CiDetector_GitLab.phpt +++ b/tests/phpt/Ci/CiDetector_GitLab.phpt @@ -2,35 +2,35 @@ GitLab CI: Detect properties --ENV-- -CI_PROJECT_NAME=ci-detector -CI_REGISTRY=registry.gitlab.com -HOSTNAME=runner-8a2f473d-project-1545369-concurrent-0 -CI_PROJECT_URL=https://gitlab.com/foo/bar -PHP_FILENAME=php-7.0.10.tar.xz CI_BUILD_BEFORE_SHA=1e50d546a67287e3111707283eb28bfff50584a9 -CI_SERVER_VERSION=8.11.0-rc5-ee CI_BUILD_ID=3265050 -CI_PROJECT_ID=1545369 -CI_RUNNER_ID=13977 -CI_PIPELINE_ID=3993609 +CI_BUILD_NAME=job1 CI_BUILD_REF_NAME=test-gitlab CI_BUILD_REF=1e50d546a67287e3111707283eb28bfff50584a9 +CI_BUILD_REPO=https://gitlab-ci-token:xxxxxx@gitlab.com/foo/bar.git CI_BUILD_STAGE=test +CI_PIPELINE_ID=3993609 CI_PROJECT_DIR=/builds/OndraM/ci-detector -CI_RUNNER_TAGS=git-annex, mongo, postgres, mysql, ruby, linux, docker, shared +CI_PROJECT_ID=1545369 +CI_PROJECT_NAME=ci-detector +CI_PROJECT_NAMESPACE=foo +CI_PROJECT_PATH=foo/bar +CI_PROJECT_URL=https://gitlab.com/foo/bar CI_REGISTRY_IMAGE=registry.gitlab.com/foo/bar -PWD=/builds/foo/bar +CI_REGISTRY=registry.gitlab.com +CI_RUNNER_DESCRIPTION=shared-runners-manager-1.gitlab.com +CI_RUNNER_ID=13977 +CI_RUNNER_TAGS=git-annex, mongo, postgres, mysql, ruby, linux, docker, shared CI_SERVER_NAME=GitLab -CI_PROJECT_PATH=foo/bar -GITLAB_CI=true CI_SERVER_REVISION=353eed7 -CI_BUILD_NAME=job1 +CI_SERVER_VERSION=8.11.0-rc5-ee CI_SERVER=yes CI=true -CI_PROJECT_NAMESPACE=foo -CI_BUILD_REPO=https://gitlab-ci-token:xxxxxx@gitlab.com/foo/bar.git -CI_RUNNER_DESCRIPTION=shared-runners-manager-1.gitlab.com +GITLAB_CI=true +HOSTNAME=runner-8a2f473d-project-1545369-concurrent-0 +PHP_FILENAME=php-7.0.10.tar.xz PHP_VERSION=7.0.10 +PWD=/builds/foo/bar --FILE-- detect(); echo "Is pull request:\n"; var_dump($ci->isPullRequest()->describe()); +echo "Git branch:\n"; +var_dump($ci->getGitBranch()); --EXPECT-- Is pull request: string(3) "Yes" +Git branch: +string(11) "test-gitlab" diff --git a/tests/phpt/Ci/CiDetector_GitLabMergeRequest.phpt b/tests/phpt/Ci/CiDetector_GitLabMergeRequest.phpt index 21cb1bd..0f8e35d 100644 --- a/tests/phpt/Ci/CiDetector_GitLabMergeRequest.phpt +++ b/tests/phpt/Ci/CiDetector_GitLabMergeRequest.phpt @@ -2,36 +2,36 @@ GitLab CI: Detect properties of PR build --ENV-- -CI_PROJECT_NAME=ci-detector -CI_REGISTRY=registry.gitlab.com -HOSTNAME=runner-8a2f473d-project-1545369-concurrent-0 -CI_PROJECT_URL=https://gitlab.com/foo/bar -PHP_FILENAME=php-7.0.10.tar.xz CI_BUILD_BEFORE_SHA=1e50d546a67287e3111707283eb28bfff50584a9 -CI_SERVER_VERSION=8.11.0-rc5-ee CI_BUILD_ID=3265050 -CI_PROJECT_ID=1545369 -CI_RUNNER_ID=13977 -CI_PIPELINE_ID=3993609 +CI_BUILD_NAME=job1 CI_BUILD_REF_NAME=test-gitlab CI_BUILD_REF=1e50d546a67287e3111707283eb28bfff50584a9 +CI_BUILD_REPO=https://gitlab-ci-token:xxxxxx@gitlab.com/foo/bar.git CI_BUILD_STAGE=test +CI_MERGE_REQUEST_ID=43 +CI_PIPELINE_ID=3993609 CI_PROJECT_DIR=/builds/OndraM/ci-detector -CI_RUNNER_TAGS=git-annex, mongo, postgres, mysql, ruby, linux, docker, shared +CI_PROJECT_ID=1545369 +CI_PROJECT_NAME=ci-detector +CI_PROJECT_NAMESPACE=foo +CI_PROJECT_PATH=foo/bar +CI_PROJECT_URL=https://gitlab.com/foo/bar CI_REGISTRY_IMAGE=registry.gitlab.com/foo/bar -PWD=/builds/foo/bar +CI_REGISTRY=registry.gitlab.com +CI_RUNNER_DESCRIPTION=shared-runners-manager-1.gitlab.com +CI_RUNNER_ID=13977 +CI_RUNNER_TAGS=git-annex, mongo, postgres, mysql, ruby, linux, docker, shared CI_SERVER_NAME=GitLab -CI_PROJECT_PATH=foo/bar -GITLAB_CI=true CI_SERVER_REVISION=353eed7 -CI_BUILD_NAME=job1 +CI_SERVER_VERSION=8.11.0-rc5-ee CI_SERVER=yes CI=true -CI_PROJECT_NAMESPACE=foo -CI_BUILD_REPO=https://gitlab-ci-token:xxxxxx@gitlab.com/foo/bar.git -CI_RUNNER_DESCRIPTION=shared-runners-manager-1.gitlab.com +GITLAB_CI=true +HOSTNAME=runner-8a2f473d-project-1545369-concurrent-0 +PHP_FILENAME=php-7.0.10.tar.xz PHP_VERSION=7.0.10 -CI_MERGE_REQUEST_ID=43 +PWD=/builds/foo/bar --FILE-- detect(); echo "Is pull request:\n"; var_dump($ci->isPullRequest()->describe()); +echo "Git branch:\n"; +var_dump($ci->getGitBranch()); --EXPECT-- Is pull request: string(3) "Yes" +Git branch: +string(11) "test-gitlab" diff --git a/tests/phpt/Ci/CiDetector_Jenkins.phpt b/tests/phpt/Ci/CiDetector_Jenkins.phpt index 7f955a5..f8e8ce2 100644 --- a/tests/phpt/Ci/CiDetector_Jenkins.phpt +++ b/tests/phpt/Ci/CiDetector_Jenkins.phpt @@ -2,22 +2,22 @@ Jenkins CI: Detect properties --ENV-- -BUILD_URL=http://jenkins.foo/job/foo_job_name/1337/ -HUDSON_SERVER_COOKIE=foo -BUILD_TAG=jenkins-foo_job_name-1337 -GIT_PREVIOUS_COMMIT=783de14cf438a41a60af7cd148a43da74ccd11cc -GIT_COMMIT=11cc783de14cf438a41a60af7cd148a43da74ccd -WORKSPACE=/srv/jenkins/workspace/foo_job_name -JOB_URL=http://jenkins.foo/job/foo_job_name/ -JOB_NAME=foo_job_name -BUILD_DISPLAY_NAME=#1337 -JENKINS_URL=http://jenkins.foo/ BUILD_CAUSE=MANUALTRIGGER +BUILD_DISPLAY_NAME=#1337 BUILD_ID=2016-07-29_20-30-09 +BUILD_NUMBER=1337 +BUILD_TAG=jenkins-foo_job_name-1337 +BUILD_URL=http://jenkins.foo/job/foo_job_name/1337/ GIT_BRANCH=origin/branchname +GIT_COMMIT=11cc783de14cf438a41a60af7cd148a43da74ccd +GIT_PREVIOUS_COMMIT=783de14cf438a41a60af7cd148a43da74ccd11cc GIT_URL=ssh://git@gitserver:7999/project/repo.git +HUDSON_SERVER_COOKIE=foo JENKINS_SERVER_COOKIE=foobar -BUILD_NUMBER=1337 +JENKINS_URL=http://jenkins.foo/ +JOB_NAME=foo_job_name +JOB_URL=http://jenkins.foo/job/foo_job_name/ +WORKSPACE=/srv/jenkins/workspace/foo_job_name --FILE--