Repository: codecov/codecov-python

Issue:
Add support for Jenkins Blue Ocean
See codecov/codecov-node#55

Discussion:

Patch:
diff --git a/.gitignore b/.gitignore
index b0b83c5..79d2d87 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
 *.egg
 *.egg-info
 *.pyc
+.cache
 .coverage
 .DS_Store
 .tox
diff --git a/codecov/__init__.py b/codecov/__init__.py
index 87cf47f..955adc3 100644
--- a/codecov/__init__.py
+++ b/codecov/__init__.py
@@ -276,10 +276,10 @@ def main(*argv, **kwargs):
         if os.getenv('JENKINS_URL'):
             # https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project
             # https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin#GitHubpullrequestbuilderplugin-EnvironmentVariables
-            query.update(dict(branch=os.getenv('ghprbSourceBranch') or os.getenv('GIT_BRANCH'),
+            query.update(dict(branch=os.getenv('ghprbSourceBranch') or os.getenv('GIT_BRANCH') or os.getenv('BRANCH_NAME'),
                               service='jenkins',
                               commit=os.getenv('ghprbActualCommit') or os.getenv('GIT_COMMIT'),
-                              pr=os.getenv('ghprbPullId', 'false'),
+                              pr=os.getenv('ghprbPullId') or os.getenv('CHANGE_ID'),
                               build=os.getenv('BUILD_NUMBER'),
                               build_url=os.getenv('BUILD_URL')))
             root = os.getenv('WORKSPACE') or root


Test patch:
diff --git a/tests/test.py b/tests/test.py
index cf54afe..2b7b98d 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -46,7 +46,7 @@ class TestUploader(unittest.TestCase):
                     "APPVEYOR_BUILD_VERSION", "APPVEYOR_JOB_ID", "APPVEYOR_REPO_NAME", "APPVEYOR_REPO_COMMIT", "WERCKER_GIT_BRANCH",
                     "WERCKER_MAIN_PIPELINE_STARTED", "WERCKER_GIT_OWNER", "WERCKER_GIT_REPOSITORY",
                     "CI_BUILD_REF_NAME", "CI_BUILD_ID", "CI_BUILD_REPO", "CI_PROJECT_DIR", "CI_BUILD_REF", "CI_SERVER_NAME",
-                    "ghprbActualCommit", "ghprbSourceBranch", "ghprbPullId", "WERCKER_GIT_COMMIT"):
+                    "ghprbActualCommit", "ghprbSourceBranch", "ghprbPullId", "WERCKER_GIT_COMMIT", "CHANGE_ID"):
             os.environ[key] = ""
 
     def tearDown(self):
@@ -339,6 +339,23 @@ class TestUploader(unittest.TestCase):
         self.assertEqual(res['query']['branch'], 'master')
         self.assertEqual(res['codecov'].token, 'token')
 
+    def test_ci_jenkins_blue_ocean(self):
+        self.set_env(JENKINS_URL='https://....',
+                     BUILD_URL='https://....',
+                     BRANCH_NAME='master',
+                     CHANGE_ID='1',
+                     BUILD_NUMBER='41',
+                     CODECOV_TOKEN='token')
+        self.fake_report()
+        res = self.run_cli()
+        self.assertEqual(res['query']['service'], 'jenkins')
+        self.assertEqual(res['query']['commit'], codecov.check_output(("git", "rev-parse", "HEAD")))
+        self.assertEqual(res['query']['build'], '41')
+        self.assertEqual(res['query']['build_url'], 'https://....')
+        self.assertEqual(res['query']['pr'], '1')
+        self.assertEqual(res['query']['branch'], 'master')
+        self.assertEqual(res['codecov'].token, 'token')
+
     def test_ci_travis(self):
         self.set_env(TRAVIS="true",
                      TRAVIS_BRANCH="master",