appleboy / drone-scp

Copy files and artifacts via SSH using a binary, docker or Drone CI.
MIT License
144 stars 30 forks source link

'drone-scp error: Process exited with status 1 0s exit code 1 notify 1' #30

Closed asaf closed 7 years ago

asaf commented 7 years ago

Hey,

I'm trying to use this plugin but I get:

2017/02/04 12:29:37 tar all files into /tmp/714504783/SKZYLBfixA.tar
2017/02/04 12:29:37 myhost.com: scp file to server.
2017/02/04 12:29:37 myhost.com: create folder /home/builds/artifacts
Process exited with status 1
drone-scp error:  Process exited with status 1

I guess it fails to create the folder, any clue?

Thanks

appleboy commented 7 years ago

@asaf Please check you have permission to create folder.

asaf commented 7 years ago

@appleboy yea i do, I can sftp using the same credentials and create folders.

asaf commented 7 years ago

Apologies, I had one missing level folder in the tree,

Now I see:

drone-scp error:  ssh: unexpected packet in response to channel open: <nil>
ssh: unexpected packet in response to channel open: <nil>
appleboy commented 7 years ago

Can you try another server out? I can't reproduce this error on my machine.

asaf commented 7 years ago

It seems like my ssh server sometimes return connection reset due to some mixture between pass/key auths, not sure, seems like it has nothing to do with this plugin :-)

Unrelated to this issue, before I close it, I was wondering,

The artifact created by our 'Makefile' is always static name, while I'd like to publish an artifact with a name such as app_TAG

Is that possible? I can't see a way to rename the source file,

Thanks for the quick responses :-)

appleboy commented 7 years ago

@asaf

You can user GIT tag on Makefile. Try ${DRONE_TAG} variable. Find all variables on http://readme.drone.io/usage/environment-reference/

asaf commented 7 years ago

@appleboy yea that will work too, i was wondering if I can just do target/newFileName (but it seems that target is just the folder name)

Maybe it makes more sense to let the artifact generate step to take care of the name instead of making the transfer plugin rename the file.

Thanks @appleboy :-)

great work btw,

appleboy commented 7 years ago

@asaf You can try drone-ssh plugin https://github.com/appleboy/drone-ssh. What is your scenario? Why did you need to change the file name?

asaf commented 7 years ago

There are two options to publish artifacts with tag name.

  1. To make the Makefile append the DRONE_TAG to the final artifact
  2. Make the transfer tool (such as this SCP one) to transfer artifact -> /artifact-DRONE_TAG.

so that's fine, i'll modify the Makefile to generate the correct artifact name with TAG postfix and make the SCP plugin just send it as is.

Thanks

asaf commented 7 years ago

@appleboy back to this, looking at the makefile of this project, $VERSION is a dynamic calculated makefile variable which may contain tag or commit id,

I was wondering if it's possible to somehow make the SCP plugin aware of this variable in order to push the generated file via SCP,

Thanks.

appleboy commented 7 years ago

@asaf

You can try the following example:

pipeline:
+ clone:
+   image: plugins/git
+   tags: true

  scp_staging:
    image: appleboy/drone-scp
    pull: true
    host: xxxx
    port: xxx
    username: xxxx
    target: /home/deploy/drone/${DRONE_TAG}
    source:
      - release.tar.gz
    when:
      branch: master
      status: [ success ]

if you push tag, the ${DRONE_TAG} will be the v1.0 format. if you push the commit, the ${DRONE_TAG} will be the {latest_tag}_{number_of_previous_tag}_{commit_id}

asaf commented 7 years ago

I added this step to the pipeline, DRONE_TAG doesn't exist

appleboy commented 7 years ago

@asaf My apologies. You can refer to Makefile of Gorush project. https://github.com/appleboy/gorush/blob/master/Makefile#L22-L26

Thanks.

asaf commented 7 years ago

@appleboy That's what I've meant, lets say you do have a Makefile that calculates the version,

How do I make the SCP plugin aware of this 'VERSION' variable available in the Makefile?

I tried to export the VERSION from Makefile and access it in the .drone.yml file as ${VERSION} but it doesn't work.

Thanks.

appleboy commented 7 years ago

One way is creating multiple tasks as following:

  scp_tag:
    .....
    target: /home/deploy/drone/${DRONE_TAG}
    source:
      - release.tar.gz
    when:
      event: [ tag ]
      status: [ success ]

  scp_master:
    .....
    target: /home/deploy/drone/${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:7}
    source:
      - release.tar.gz
    when:
      branch: master
      status: [ success ]

Another way is implementing this feature to support VERSION variable but you need to tell me what format of VERSION variable clearly.

asaf commented 7 years ago

@appleboy yea that will work, I don't think we should make the SCP plugin aware of a specific versioning template,

I'll try to talk with Drone folks, maybe there is a way to read exported variables from Makefile,

Does it make sense to support wildcards in this SCP plugin in source field?

such as release*.tar.gz ? that would just pick up any file that matches the criteria,

Thanks

appleboy commented 7 years ago

@asaf

I create another issue to track wildcards feature. I think we should close this issue.

Thanks.

asaf commented 7 years ago

@appleboy yes indeed, closing, thanks!