# Mender-Artifact cp commands fail on jenkins

**URL:** <https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984>\
**Category:** General Discussions\
**Tags:** mender, mender-artifact, jenkins\
**Created:** [September 5, 2019, 5:22am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984 "2019-09-05T05:22:28Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shrulabh](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@Shrulabh](https://hub.mender.io/u/Shrulabh)\
**Post date:** [September 5, 2019, 5:22am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/1 "2019-09-05T05:22:28Z")

</div>

Hi,  
I’m trying to use mender-artifact **cp** and **cat** commands using jenkins. The cat commands work fine but the cp command fails to execute. Here is output from the jenkins machine.

//mender-convert

- ls

- bbb-convert-stage-2.sh
- convert-stage-3.sh
- convert-stage-4.sh
- convert-stage-5.sh
- device-image-shell
- docker-build
- docker-entrypoint.sh
- Dockerfile
- docker-mender-convert
- files
- input
- LICENSE
- LIC\_FILES\_CHKSUM.sha256
- mender-artifact
- mender-convert
- mender-convert-functions.sh
- output
- qemux86\_64-convert-stage-2.sh
- README.md
- rpi-convert-stage-2.sh
- rpi-convert-stage-5.sh
- ukey-update-artifact.sh

00:00:00.012 + sudo ./ukey-update-artifact.sh

**no artifact or sdimage provided**

_Contents of ukey-update-artifact.sh_

_./mender-artifact cat output/.mender:/etc/fstab **–\> This works** _  
_./mender-artifact cp input/mender.conf output/.mender:/etc/fstab **–\> This fails -ERROR -(no artifact or sdimage provided)**_  
_./mender-artifact rm output/:/etc/fstab --\> **This works** _

**NOTE** : When i manually run this script it works perfectly but it fails on jenkins

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [September 5, 2019, 6:25am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/2 "2019-09-05T06:25:06Z")

</div>

Hi, we stumbled across this issue ourselves just last week actually. The problem is that the scripts are fed through stdin on the machine, and mender-artifact (faulty), decides to read from stdin, instead of the two files which are listed on the command line.  
The PR with the fix can be found here: [https://github.com/mendersoftware/mender-artifact/pull/215](https://github.com/mendersoftware/mender-artifact/pull/215). Please note that the implementation now (with this PR), requires the use of ‘-’ explicitly, in order to read from stdin.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [September 5, 2019, 6:28am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/3 "2019-09-05T06:28:29Z")

</div>

As a temporary workaround, you can reshape your command to:

```auto
./mender-artifact cp output/.mender:/etc/fstab < input/mender.conf

```

But please note that this workaround won’t work after this is fixed. Normally we don’t change behavior in minor releases, but I think we will make an exception here, due to the very confusing nature of this.

---

<div class="post-metadata">

**Author:** ![Shrulabh](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@Shrulabh](https://hub.mender.io/u/Shrulabh)\
**Post date:** [September 5, 2019, 6:44am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/4 "2019-09-05T06:44:06Z")

</div>

The following error comes after making the changes.  
**got 1 arguments, wants two**

I guess **cp** command is taking the whole command as one argument.

My command: **./mender-artifact cp ‘output/xyz.mender:/etc/fstab’ \< 'input/fstab’**

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [September 5, 2019, 6:49am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/5 "2019-09-05T06:49:36Z")

</div>

try cat file | mender-artifact cp artifact.mender:/path/in/update

---

<div class="post-metadata">

**Author:** ![Shrulabh](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@Shrulabh](https://hub.mender.io/u/Shrulabh)\
**Post date:** [September 5, 2019, 6:57am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/6 "2019-09-05T06:57:47Z")

</div>

Can you please tell which file should i use with **cat**. For example I need to copy a file fstab with address **input/fstab** to the mender artifact in location **etc/fstab**.

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [September 5, 2019, 7:07am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/7 "2019-09-05T07:07:47Z")

</div>

cat input/fstab | mender-artifact cp artifact.mender:/etc/fstab

---

<div class="post-metadata">

**Author:** ![Shrulabh](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@Shrulabh](https://hub.mender.io/u/Shrulabh)\
**Post date:** [September 5, 2019, 9:57am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/8 "2019-09-05T09:57:18Z")

</div>

Thank you soo much the command now works as expected…!!!  
The cp command now works and changes the .mender file

---

<div class="post-metadata">

**Author:** ![Shrulabh](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@Shrulabh](https://hub.mender.io/u/Shrulabh)\
**Post date:** [September 30, 2019, 11:34am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/9 "2019-09-30T11:34:36Z")

</div>

Hii everyone I am facing another issue. While I copy the files with the above-mentioned solution; I am getting permission issue with my files. I m modifying the mender-device-identity file with Jenkins and copying it inside the .mender file.  
Original mender-device-identity permissions : -rwxr-xr-x  
After deploying mender update to a Raspberry Pi3: -rw-----

I tried changing the permission using the commamd:  
**./mender-artifact install -m 777 input/mender-device-identity $file.mender:/usr/share/mender/identity/mender-device-identity**

But it came up with the same error as it was throwing in **cp command**

**No artifact or sdimg provided**

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [October 1, 2019, 7:20am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/10 "2019-10-01T07:20:28Z")

</div>

Hi @Shrulabh, I don’t see anything wrong with your command at first sight.  
Have you tried this command locally?  
And are you sure that `$file` resolves to a filename, without the `.mender` extension?

---

<div class="post-metadata">

**Author:** ![Shrulabh](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@Shrulabh](https://hub.mender.io/u/Shrulabh)\
**Post date:** [October 1, 2019, 10:39am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/11 "2019-10-01T10:39:08Z")

</div>

Hii @oleorhagen yes the **$file** resolves a filename and the command works locally. But the issue is that it fails in Jenkins build; with the error **No artifact or sdimg provided**

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [October 1, 2019, 11:13am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/12 "2019-10-01T11:13:41Z")

</div>

Could you show me what `$file` resolves to? 🙂

---

<div class="post-metadata">

**Author:** ![Shrulabh](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@Shrulabh](https://hub.mender.io/u/Shrulabh)\
**Post date:** [October 3, 2019, 8:09am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/13 "2019-10-03T08:09:38Z")

</div>

@oleorhagen  
**./mender-artifact install -m 777 input/mender-device-identity output/ras\_modify.mender:/usr/share/mender/identity/mender-device-identity**

This is the final command that runs in jenkins

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [October 3, 2019, 11:36am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/14 "2019-10-03T11:36:15Z")

</div>

Hmm, curious, I don’t see anything wrong with it on the surface. Could you send me the artifact in question ?

Also which version of mender-artifact are you using?

---

<div class="post-metadata">

**Author:** ![Shrulabh](https://avatars.discourse-cdn.com/v4/letter/s/74df32/32.png) [@Shrulabh](https://hub.mender.io/u/Shrulabh)\
**Post date:** [October 3, 2019, 11:41am UTC](https://hub.mender.io/t/mender-artifact-cp-commands-fail-on-jenkins/984/15 "2019-10-03T11:41:40Z")

</div>

I’m using the prebuilt mender artifact that is mentioned in the documentation of mender.  
[https://d1b0l86ne08fsf.cloudfront.net/mender-artifact/3.0.1/mender-artifact](https://d1b0l86ne08fsf.cloudfront.net/mender-artifact/3.0.1/mender-artifact) this is the link
