Public bug reported:

get_build_artifact allows to get artifacts if they are JSON files
but if they are non-json ascii files or binary files it fails

for example run this pipeline:

```
node {
    sh '''
        echo text > ascii.txt
        dd if=/dev/zero of=binary.dat bs=1c count=10
        ls -l
        cat ascii.txt
        cat binary.dat | hexdump
    '''
    writeJSON file: 'data.json', json: [ 'key': 'val']
    archiveArtifacts 'ascii.txt'
    archiveArtifacts 'binary.dat'
    archiveArtifacts 'data.json'

}
```


json artifact can be downloaded

```
>>> import jenkins
>>> j = jenkins.Jenkins('http://ci.jenkins.internal:8080/', 'jenkins', 
>>> 'jenkins')
>>> data = j.get_build_artifact('testjob', '1', 'data.json')
>>> print(data)
{'key': 'val'}
```

but not the binary one

```
>>> binary = j.get_build_artifact('testjob', '1', 'binary.dat')
Traceback (most recent call last):
  File "/workspace/python-jenkins/jenkins/__init__.py", line 731, in 
get_build_artifact
    return json.loads(response)
  File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py",
 line 357, in loads
    return _default_decoder.decode(s)
  File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py",
 line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py",
 line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/workspace/python-jenkins/jenkins/__init__.py", line 737, in 
get_build_artifact
    raise JenkinsException(
jenkins.JenkinsException: Could not parse JSON info for job[testjob] number[1]
```

nor the ascii (non-jenkins) one

```
>>> ascii = j.get_build_artifact('testjob', '1', 'ascii.txt')
Traceback (most recent call last):
  File "/workspace/python-jenkins/jenkins/__init__.py", line 731, in 
get_build_artifact
    return json.loads(response)
  File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py",
 line 357, in loads
    return _default_decoder.decode(s)
  File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py",
 line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py",
 line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/workspace/python-jenkins/jenkins/__init__.py", line 737, in 
get_build_artifact
    raise JenkinsException(
jenkins.JenkinsException: Could not parse JSON info for job[testjob] number[1]
``

** Affects: python-jenkins
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Python
Jenkins Developers, which is subscribed to Python Jenkins.
https://bugs.launchpad.net/bugs/1973243

Title:
  impossible to download artifacts that are not json-formated

Status in Python Jenkins:
  New

Bug description:
  get_build_artifact allows to get artifacts if they are JSON files
  but if they are non-json ascii files or binary files it fails

  for example run this pipeline:

  ```
  node {
      sh '''
          echo text > ascii.txt
          dd if=/dev/zero of=binary.dat bs=1c count=10
          ls -l
          cat ascii.txt
          cat binary.dat | hexdump
      '''
      writeJSON file: 'data.json', json: [ 'key': 'val']
      archiveArtifacts 'ascii.txt'
      archiveArtifacts 'binary.dat'
      archiveArtifacts 'data.json'

  }
  ```

  
  json artifact can be downloaded

  ```
  >>> import jenkins
  >>> j = jenkins.Jenkins('http://ci.jenkins.internal:8080/', 'jenkins', 
'jenkins')
  >>> data = j.get_build_artifact('testjob', '1', 'data.json')
  >>> print(data)
  {'key': 'val'}
  ```

  but not the binary one

  ```
  >>> binary = j.get_build_artifact('testjob', '1', 'binary.dat')
  Traceback (most recent call last):
    File "/workspace/python-jenkins/jenkins/__init__.py", line 731, in 
get_build_artifact
      return json.loads(response)
    File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py",
 line 357, in loads
      return _default_decoder.decode(s)
    File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py",
 line 337, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py",
 line 355, in raw_decode
      raise JSONDecodeError("Expecting value", s, err.value) from None
  json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/workspace/python-jenkins/jenkins/__init__.py", line 737, in 
get_build_artifact
      raise JenkinsException(
  jenkins.JenkinsException: Could not parse JSON info for job[testjob] number[1]
  ```

  nor the ascii (non-jenkins) one

  ```
  >>> ascii = j.get_build_artifact('testjob', '1', 'ascii.txt')
  Traceback (most recent call last):
    File "/workspace/python-jenkins/jenkins/__init__.py", line 731, in 
get_build_artifact
      return json.loads(response)
    File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py",
 line 357, in loads
      return _default_decoder.decode(s)
    File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py",
 line 337, in decode
      obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py",
 line 355, in raw_decode
      raise JSONDecodeError("Expecting value", s, err.value) from None
  json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/workspace/python-jenkins/jenkins/__init__.py", line 737, in 
get_build_artifact
      raise JenkinsException(
  jenkins.JenkinsException: Could not parse JSON info for job[testjob] number[1]
  ``

To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1973243/+subscriptions


-- 
Mailing list: https://launchpad.net/~python-jenkins-developers
Post to     : python-jenkins-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~python-jenkins-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to