curl upload with filename in variable

已查看 755 次
跳至第一个未读帖子

Curtis Kline

未读,
2017年8月9日 17:13:472017/8/9
收件人 jenkins...@googlegroups.com
In my declarative pipeline Jenkinsfile, I have the following shell script line:

sh """
curl -F "status=2" -F "notify=1" -F "notes=${params.ReleaseNotes}" -F "ipa=@${env.filename}" -H "X-HockeyAppToken: 1234" https://rink.hockeyapp.net/api/2/apps/upload
"""

This does not work, because curl is apparently unable to open the file. The file clearly exists, and the env.filename variable contains the correct filename (you can see this in the console log below, as the variable has been expanded to a file name).

A snippet of my console log is below. I’ve been working on this for a number of hours, and I could use any help or advice you might have.

[Pipeline] sh[JenkinsAndroidTest] Running shell script
+ curl -F status=2 -F notify=1 -F notes= -F ipa=@Project-debug-v2.1.0-b999.apk
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (26) couldn't open file “Project-debug-v2.1.0-b999.apk
"
[Pipeline] }

Slide

未读,
2017年8月9日 17:26:212017/8/9
收件人 jenkins...@googlegroups.com
Does the file exist in what would be considered the current working directory? Perhaps an ls before the curl to verify?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAGkg-enyw40%3DHNoD85ai%2BFemMjafkJwH9jsswGhJX-KmAr8Qig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Curtis Kline

未读,
2017年8月9日 17:40:582017/8/9
收件人 jenkins...@googlegroups.com
The file exists in the current working directory. This is a three-stage project with the agent declared at the global level. It's not running in a Docker container, simply on a Linux node. As a test, I included a step right before the one I mentioned:

            ls -l ${env.filename}

The results seem conclusive:

[Pipeline] sh
[JenkinsAndroidTest] Running shell script
+ ls -l Project-debug-v2.1.0-b999.apk
-rwxrwxrwx 1 jenkins jenkins 33014841 Aug  9 21:01 Project-debug-v2.1.0-b999.apk



On Wed, Aug 9, 2017 at 4:26 PM, Slide <slide...@gmail.com> wrote:
Does the file exist in what would be considered the current working directory? Perhaps an ls before the curl to verify?

On Wed, Aug 9, 2017 at 2:13 PM Curtis Kline <curti...@gmail.com> wrote:
In my declarative pipeline Jenkinsfile, I have the following shell script line:

sh """
curl -F "status=2" -F "notify=1" -F "notes=${params.ReleaseNotes}" -F "ipa=@${env.filename}" -H "X-HockeyAppToken: 1234" https://rink.hockeyapp.net/api/2/apps/upload
"""

This does not work, because curl is apparently unable to open the file. The file clearly exists, and the env.filename variable contains the correct filename (you can see this in the console log below, as the variable has been expanded to a file name).

A snippet of my console log is below. I’ve been working on this for a number of hours, and I could use any help or advice you might have.

[Pipeline] sh[JenkinsAndroidTest] Running shell script
+ curl -F status=2 -F notify=1 -F notes= -F ipa=@Project-debug-v2.1.0-b999.apk
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (26) couldn't open file “Project-debug-v2.1.0-b999.apk
"
[Pipeline] }

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVfa%2BX14jd_4LvX1CYS_vuWRSYmvvHSh3dHjM9_ApMo5-g%40mail.gmail.com.

Victor Martinez

未读,
2017年8月10日 03:41:072017/8/10
收件人 Jenkins Users、curti...@gmail.com
Couple of thoughts:

- ${params.ReleaseNotes} doesn't look it got any value, then it might be one of the root causes, 
- if you use the -v flag, does it give you any details?


sh """
ls -l
${env.filename}
curl -v -F "status=2" -F "notify=1" -F "notes=${params.ReleaseNotes}" -F "ipa=@${env.filename}" -H "X-HockeyAppToken: 1234" https://rink.hockeyapp.net/api/2/apps/upload
"""


Cheers

Richard Bywater

未读,
2017年8月10日 06:16:492017/8/10
收件人 jenkins...@googlegroups.com
Taking a look at the error, it appears like you have a line feed or carriage return at the end of the env.filename variable (note the quote is on the next line and not next to apk like I'd expect). 

Richard.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAGkg-enQf5Wd00PPtkNnatYKNcmFjPDxHAoj94JakZe18U88Yg%40mail.gmail.com.

Curtis Kline

未读,
2017年8月10日 17:01:012017/8/10
收件人 jenkins...@googlegroups.com
Richard, that was the problem. There was an extra line feed stuffed into the variable by accident.

Thanks!
Curtis


Richard.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAMui945v4%3DR_nEFBQ4PyZHN_7vVXsRqFsqEDNgp1Gi2rCd0n-A%40mail.gmail.com.
回复全部
回复作者
转发
0 个新帖子