Closed droplet-js closed 4 years ago
Hey @v7lin. I found an alternative by ssh-ing into the client system, executing scp from there to send the file back to the host drone instance and then mounting the file into the agent as a volume. Not the best way to do it, agreed, but it works. This might help you as well.
Hey @v7lin. I found an alternative by ssh-ing into the client system, executing scp from there to send the file back to the host drone instance and then mounting the file into the agent as a volume. Not the best way to do it, agreed, but it works. This might help you as well.
which docker images?
@v7lin What is the scenario you want to copy data from ssh-server to drone-agent?
i want to use drone-ssh to build iOS App, and i want to copy the result ipa to drone-agent
Similar situation here. I have a mac build that I send to a remote system to build, then use drone-ssh
to execute the build and then use the (in-built) scp
to send the built file back to my agent
@appleboy
example:
---
kind: pipeline
name: build-ios
steps:
- name: scp
image: appleboy/drone-scp
settings:
host: host.docker.internal
port: 22
username:
from_secret: MAC_USER
password:
from_secret: MAC_PASSWORD
source: ./*
target: ~/.drone-build/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/${DRONE_BUILD_NUMBER}
rm: true
- name: prepare
image: appleboy/drone-ssh
settings:
host: host.docker.internal
port: 22
username:
from_secret: MAC_USER
password:
from_secret: MAC_PASSWORD
command_timeout: 10m
script_stop: true
script:
- BUILD_DIR=~/.drone-build/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/${DRONE_BUILD_NUMBER}
- cd $BUILD_DIR
- bash -lc 'flutter packages get'
- if [ $? -ne 0 ]; then exit 1; fi; # 断言
- name: build-ios
image: appleboy/drone-ssh
settings:
host: host.docker.internal
port: 22
username:
from_secret: MAC_USER
password:
from_secret: MAC_PASSWORD
command_timeout: 10m
script_stop: true
script:
- BUILD_DIR=~/.drone-build/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/${DRONE_BUILD_NUMBER}
- cd $BUILD_DIR
- bash -lc 'flutter -v build ios --no-codesign'
- if [ $? -ne 0 ]; then exit 1; fi; # 断言
- name: clear
image: appleboy/drone-ssh
settings:
host: host.docker.internal
port: 22
username:
from_secret: MAC_USER
password:
from_secret: MAC_PASSWORD
command_timeout: 10m
script_stop: true
script:
- BUILD_DIR=~/.drone-build/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/${DRONE_BUILD_NUMBER}
- rm -rf $BUILD_DIR
when:
status:
- success
- failure
trigger:
status:
- success
event:
- tag
depends_on:
- default
node:
os: macos
Please change the command_timeout: 600
to command_timeout: 10m
in the latest version.
You can merge the build-ios
and prepare
steps?
name: build-ios
image: appleboy/drone-ssh
settings:
host: host.docker.internal
port: 22
username:
from_secret: MAC_USER
password:
from_secret: MAC_PASSWORD
- command_timeout: 600
+ command_timeout: 60m
+ script_stop: true
script:
- BUILD_DIR=~/.drone-build/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/${DRONE_BUILD_NUMBER}
- cd $BUILD_DIR
- bash -lc 'flutter -v build ios --no-codesign'
- bash -lc 'flutter -v build ios --no-codesign'
@appleboy ^_^
@v7lin Also add the script_stop: true
to stop the build if fail in steps.
@appleboy ^_^ thanks
@v7lin @rakshith-ravi Drone support mac agent in v1.0 version so you can run build in mac and copy to a remote server using drone-scp plugin. See the Exec Runnder.
@appleboy 我尝试了一下 Exec Runner 其工具还不完善,而且安装工具会污染 Mac 机器的编译环境(编译 ipa),我还是坚持想要 drone-scp 支持从 ssh-server 拷贝数据到 /drone/src 编译目录下,然后借助丰富的 docker 工具完成其他自动化工作。谢谢!
Something that I did was mount a volume and fetch from remote with a native scp:
- name: restore-artifact
image: kroniak/ssh-client
environment:
PRIVATE_SSH_KEY:
from_secret: private-ssh-key
REMOTE_HOST: "user@127.0.0.1"
volumes:
- name: build_files
path: /build_files
commands:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- echo "$PRIVATE_SSH_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- scp -r $REMOTE_HOST:~/build/files/* /build_files
I'm facing this issue as well. @appleboy could you help us please?