meltwater / drone-cache

A Drone plugin for caching current workspace files between builds to reduce your build times
https://underthehood.meltwater.com/blog/2019/04/10/making-drone-builds-10-times-faster/
Apache License 2.0
338 stars 81 forks source link

uncaught error, initialize backend <sftp>, initialize backend, unable to get ssh auth method, unknown ssh method (PASSWORD, PUBLIC_KEY_FILE) #244

Closed king1107955613 closed 1 year ago

king1107955613 commented 1 year ago

Describe the bug SFPT init failed

To Reproduce Steps to reproduce the behavior:

  1. Using ... config

    image: meltwater/drone-cache:v1.4.0-linux-amd64
    pull: true
    settings:
    backend: sftp
    restore: true
    debug: true
    sftp.cache-root: /d/drone
    
    sftp.host:
      from_secret: host
    sftp.username:
      from_secret: sshname
    sftp.auth-method: PASSWORD
    sftp.password:
      from_secret: password
    sftp.port: 22
    
    volumes:
      - name: cache
        path: /drone
  2. While ... i try use sftp.authMethodPLUGIN_SFTP.AUTH_METHODSSHAuthMethodSSHAuth.Method ,but norworking

  3. See error

log here

PH VIEW
0m 6s
Mar 21, 2023, 11:03 PM

archivetest
31351

waps
waps
pushed
28950525
to
main
PIPELINE STAGES
1 stage

default
clone
Cache
Clear Dir
Scp Download Files
Build Plugins
remove source and Build
CONSOLE LOGS

level=info name=drone-cache ts=2023-03-21T15:03:11.217659798Z caller=main.go:506 version=dev commit=none date=unknown
level=debug name=drone-cache ts=2023-03-21T15:03:11.217775372Z caller=plugin.go:51 component=plugin msg="DEBUG MODE enabled!"
level=debug name=drone-cache ts=2023-03-21T15:03:11.217818596Z caller=plugin.go:54 component=plugin var="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
level=debug name=drone-cache ts=2023-03-21T15:03:11.217849853Z caller=plugin.go:54 component=plugin var="HOSTNAME=5f139281f926"
level=debug name=drone-cache ts=2023-03-21T15:03:11.217886141Z caller=plugin.go:54 component=plugin var="DRONE_SYSTEM_HOSTNAME=192.168.1.103:3080"
level=debug name=drone-cache ts=2023-03-21T15:03:11.217921618Z caller=plugin.go:54 component=plugin var="DRONE_REMOTE_URL=http://192.168.1.103:3030/waps/archivetest.git"
level=debug name=drone-cache ts=2023-03-21T15:03:11.217947992Z caller=plugin.go:54 component=plugin var="CI_COMMIT_AUTHOR_NAME=waps"
level=debug name=drone-cache ts=2023-03-21T15:03:11.217974861Z caller=plugin.go:54 component=plugin var="DRONE_BUILD_DEBUG=false"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218007648Z caller=plugin.go:54 component=plugin var="CI_BUILD_EVENT=push"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218035991Z caller=plugin.go:54 component=plugin var="CI_BUILD_STATUS=pending"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218060387Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT_MESSAGE=31351\n"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218084313Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_OS=linux"
level=debug name=drone-cache ts=2023-03-21T15:03:11.21810776Z caller=plugin.go:54 component=plugin var="PLUGIN_BACKEND=sftp"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218131359Z caller=plugin.go:54 component=plugin var="PLUGIN_DEBUG=true"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218182172Z caller=plugin.go:54 component=plugin var="DRONE_BUILD_LINK=http://192.168.1.103:3080/waps/archivetest/79"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218206722Z caller=plugin.go:54 component=plugin var="DRONE_WORKSPACE_BASE=/drone/src"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218230381Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_ARCH=amd64"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218253757Z caller=plugin.go:54 component=plugin var="CI_COMMIT_AUTHOR_EMAIL=king1107955613@outlook.com"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218277419Z caller=plugin.go:54 component=plugin var="DRONE_BUILD_PARENT=0"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218302759Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_KIND=pipeline"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218326345Z caller=plugin.go:54 component=plugin var="GIT_TERMINAL_PROMPT=0"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218351342Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_NUMBER=1"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218376931Z caller=plugin.go:54 component=plugin var="DRONE_SYSTEM_VERSION=2.16.0"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218400663Z caller=plugin.go:54 component=plugin var="GIT_AUTHOR_EMAIL=king1107955613@outlook.com"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218424434Z caller=plugin.go:54 component=plugin var="DRONE_BUILD_FINISHED=1679410990"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218447964Z caller=plugin.go:54 component=plugin var="CI_BUILD_CREATED=1679410985"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218471562Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT_AFTER=28950525dbaacadc655c55c814835b061c162096"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218498677Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_TYPE=docker"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218522865Z caller=plugin.go:54 component=plugin var="CI_REPO_LINK=http://192.168.1.103:3030/waps/archivetest"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218552013Z caller=plugin.go:54 component=plugin var="DRONE_REPO=waps/archivetest"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218576429Z caller=plugin.go:54 component=plugin var="DRONE_REPO_VISIBILITY=public"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218600537Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_STARTED=1679410985"
level=debug name=drone-cache ts=2023-03-21T15:03:11.21862556Z caller=plugin.go:54 component=plugin var="GIT_COMMITTER_EMAIL=king1107955613@outlook.com"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218649706Z caller=plugin.go:54 component=plugin var="DRONE_SOURCE_BRANCH=main"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218675258Z caller=plugin.go:54 component=plugin var="DRONE_REPO_PRIVATE=false"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218698976Z caller=plugin.go:54 component=plugin var="GIT_COMMITTER_NAME=waps"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218722387Z caller=plugin.go:54 component=plugin var="DRONE_BUILD_EVENT=push"
level=debug name=drone-cache ts=2023-03-21T15:03:11.2187459Z caller=plugin.go:54 component=plugin var="DRONE_REPO_NAME=archivetest"
level=debug name=drone-cache ts=2023-03-21T15:03:11.21876945Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT_AUTHOR_EMAIL=king1107955613@outlook.com"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218793046Z caller=plugin.go:54 component=plugin var="DRONE_BUILD_STARTED=1679410990"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218816963Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT_BEFORE=f41ffa9f1f4d3d8c3fe24da289fc2cfe15f55f00"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218842406Z caller=plugin.go:54 component=plugin var="CI_REMOTE_URL=http://192.168.1.103:3030/waps/archivetest.git"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218868781Z caller=plugin.go:54 component=plugin var="DRONE_SYSTEM_PROTO=http"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218893432Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_STATUS=success"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218916987Z caller=plugin.go:54 component=plugin var="DRONE_REPO_OWNER=waps"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218940265Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT_REF=refs/heads/main"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218965031Z caller=plugin.go:54 component=plugin var="DRONE_DOCKER_NETWORK_ID=drone-dktmCLO8QUfllT980Zmm"
level=debug name=drone-cache ts=2023-03-21T15:03:11.218988888Z caller=plugin.go:54 component=plugin var="PLUGIN_RESTORE=true"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219012308Z caller=plugin.go:54 component=plugin var="DRONE_BUILD_CREATED=1679410985"
level=debug name=drone-cache ts=2023-03-21T15:03:11.21903562Z caller=plugin.go:54 component=plugin var="DRONE_REPO_NAMESPACE=waps"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219059038Z caller=plugin.go:54 component=plugin var="GIT_AUTHOR_NAME=waps"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219085974Z caller=plugin.go:54 component=plugin var="DRONE_REPO_LINK=http://192.168.1.103:3030/waps/archivetest"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219111161Z caller=plugin.go:54 component=plugin var="CI_REPO_REMOTE=http://192.168.1.103:3030/waps/archivetest.git"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219135294Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT=28950525dbaacadc655c55c814835b061c162096"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219183177Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_FINISHED=1679410990"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219207575Z caller=plugin.go:54 component=plugin var="DRONE_STEP_NUMBER=2"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219231232Z caller=plugin.go:54 component=plugin var="DRONE_CARD_PATH=/dev/stdout"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219254536Z caller=plugin.go:54 component=plugin var="CI_PARENT_BUILD_NUMBER=0"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219278015Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT_LINK=http://192.168.1.103:3030/waps/archivetest/compare/f41ffa9f1f4d3d8c3fe24da289fc2cfe15f55f00...28950525dbaacadc655c55c814835b061c162096"
level=debug name=drone-cache ts=2023-03-21T15:03:11.21930367Z caller=plugin.go:54 component=plugin var="DRONE_TARGET_BRANCH=main"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219327377Z caller=plugin.go:54 component=plugin var="DRONE_BUILD_TRIGGER=@hook"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219352808Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT_AUTHOR_AVATAR=http://192.168.1.103:3030/avatars/08baca74d4e73a09bf0af370451a6d26"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219378035Z caller=plugin.go:54 component=plugin var="DRONE_REPO_BRANCH=main"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219403662Z caller=plugin.go:54 component=plugin var="DRONE_WORKSPACE=/drone/src"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219427355Z caller=plugin.go:54 component=plugin var="PLUGIN_SFTP.AUTH-METHOD=PASSWORD"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219452158Z caller=plugin.go:54 component=plugin var="CI_REPO_PRIVATE=false"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219475488Z caller=plugin.go:54 component=plugin var="DRONE_DEPLOY_ID=0"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219498724Z caller=plugin.go:54 component=plugin var="CI=true"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219524065Z caller=plugin.go:54 component=plugin var="DRONE_BUILD_STATUS=success"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219547608Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_NAME=default"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219570974Z caller=plugin.go:54 component=plugin var="DRONE_SYSTEM_HOST=192.168.1.103:3080"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219594576Z caller=plugin.go:54 component=plugin var="DRONE_BUILD_NUMBER=79"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219617962Z caller=plugin.go:54 component=plugin var="DRONE_DOCKER_VOLUME_ID=drone-LBDL1RVCVFv6rQtK0mMP"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219643328Z caller=plugin.go:54 component=plugin var="PLUGIN_VOLUMES=[{\"name\":\"cache\",\"path\":\"/drone\"}]"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219668104Z caller=plugin.go:54 component=plugin var="PLUGIN_SFTP.PORT=22"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219691481Z caller=plugin.go:54 component=plugin var="CI_COMMIT_REF=refs/heads/main"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219714793Z caller=plugin.go:54 component=plugin var="CI_BUILD_NUMBER=79"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219745821Z caller=plugin.go:54 component=plugin var="CI_BUILD_LINK=http://192.168.1.103:3030/waps/archivetest/compare/f41ffa9f1f4d3d8c3fe24da289fc2cfe15f55f00...28950525dbaacadc655c55c814835b061c162096"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219770926Z caller=plugin.go:54 component=plugin var="DRONE=true"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219794158Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_VERSION=3"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219824295Z caller=plugin.go:54 component=plugin var="CI_COMMIT_SHA=28950525dbaacadc655c55c814835b061c162096"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219849168Z caller=plugin.go:54 component=plugin var="CI_REPO=waps/archivetest"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219872661Z caller=plugin.go:54 component=plugin var="DRONE_STEP_NAME=Cache"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219896086Z caller=plugin.go:54 component=plugin var="DRONE_GIT_SSH_URL=ssh://gitea@192.168.1.103:3022/waps/archivetest.git"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219922102Z caller=plugin.go:54 component=plugin var="CI_BUILD_FINISHED=0"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219945823Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT_SHA=28950525dbaacadc655c55c814835b061c162096"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219972989Z caller=plugin.go:54 component=plugin var="DRONE_GIT_HTTP_URL=http://192.168.1.103:3030/waps/archivetest.git"
level=debug name=drone-cache ts=2023-03-21T15:03:11.219997442Z caller=plugin.go:54 component=plugin var="CI_COMMIT_AUTHOR_AVATAR=http://192.168.1.103:3030/avatars/08baca74d4e73a09bf0af370451a6d26"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220023339Z caller=plugin.go:54 component=plugin var="CI_BUILD_STARTED=0"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220047071Z caller=plugin.go:54 component=plugin var="DRONE_BRANCH=main"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220071879Z caller=plugin.go:54 component=plugin var="CI_COMMIT_MESSAGE=31351\n"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220095592Z caller=plugin.go:54 component=plugin var="PLUGIN_SFTP.CACHE-ROOT=/d/drone"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220120602Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT_BRANCH=main"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220163956Z caller=plugin.go:54 component=plugin var="DRONE_COMMIT_AUTHOR_NAME=waps"
level=debug name=drone-cache ts=2023-03-21T15:03:11.22018938Z caller=plugin.go:54 component=plugin var="CI_REPO_NAME=waps/archivetest"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220212804Z caller=plugin.go:54 component=plugin var="CI_COMMIT_BRANCH=main"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220238386Z caller=plugin.go:54 component=plugin var="DRONE_STAGE_MACHINE=docker-runner"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220262148Z caller=plugin.go:54 component=plugin var="PLUGIN_SFTP.PASSWORD=******"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220297254Z caller=plugin.go:54 component=plugin var="PLUGIN_SFTP.HOST=******"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220321095Z caller=plugin.go:54 component=plugin var="PLUGIN_SFTP.USERNAME=******"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220352518Z caller=plugin.go:54 component=plugin var="HOME=/"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220441921Z caller=plugin.go:57 component=plugin msg="plugin initialized wth config" config="plugin.Config{ArchiveFormat:\"tar\", Backend:\"sftp\", CacheKeyTemplate:\"\", RemoteRoot:\"\", LocalRoot:\"\", Debug:true, Rebuild:false, Restore:true, SkipSymlinks:false, Override:true, CompressionLevel:-1, StorageOperationTimeout:180000000000, Mount:[]string(nil), S3:s3.Config{ACL:\"private\", Bucket:\"\", Encryption:\"\", Endpoint:\"\", Key:\"\", StsEndpoint:\"\", RoleArn:\"\", Region:\"\", Secret:\"\", PathStyle:false, Public:false}, FileSystem:filesystem.Config{CacheRoot:\"/tmp/cache\"}, SFTP:sftp.Config{CacheRoot:\"\", Username:\"\", Host:\"\", Port:\"\", Auth:sftp.SSHAuth{Password:\"\", PublicKeyFile:\"\", Method:\"\"}, Timeout:180000000000}, Azure:azure.Config{AccountName:\"\", AccountKey:\"\", ContainerName:\"\", BlobStorageURL:\"blob.core.windows.net\", Azurite:false, MaxRetryRequests:0, Timeout:180000000000}, GCS:gcs.Config{Bucket:\"\", ACL:\"\", Encryption:\"\", Endpoint:\"\", APIKey:\"\", JSONKey:\"\", Timeout:180000000000}, Alioss:alioss.Config{Bucket:\"\", Endpoint:\"\", AccesKeyID:\"\", AccesKeySecret:\"\"}}"
level=debug name=drone-cache ts=2023-03-21T15:03:11.220534827Z caller=plugin.go:58 component=plugin msg="plugin initialized with metadata" metadata="metadata.Metadata{Build:metadata.Build{Created:1679410985, Deploy:\"\", Event:\"push\", Finished:1679410990, Link:\"http://192.168.1.103:3080/waps/archivetest/79\", Number:79, Started:1679410990, Status:\"success\"}, Commit:metadata.Commit{Author:metadata.Author{Avatar:\"http://192.168.1.103:3030/avatars/08baca74d4e73a09bf0af370451a6d26\", Email:\"king1107955613@outlook.com\", Name:\"\"}, Branch:\"main\", Link:\"http://192.168.1.103:3030/waps/archivetest/compare/f41ffa9f1f4d3d8c3fe24da289fc2cfe15f55f00...28950525dbaacadc655c55c814835b061c162096\", Message:\"31351\\n\", Ref:\"28950525dbaacadc655c55c814835b061c162096\", Remote:\"http://192.168.1.103:3030/waps/archivetest.git\", Sha:\"28950525dbaacadc655c55c814835b061c162096\"}, Repo:metadata.Repo{Avatar:\"\", Branch:\"main\", Link:\"http://192.168.1.103:3030/waps/archivetest\", Name:\"archivetest\", Namespace:\"waps\", Owner:\"waps\", Private:false, Trusted:false}}"
level=warn name=drone-cache ts=2023-03-21T15:03:11.220585929Z caller=backend.go:83 component=plugin msg="using sftp as backend"
2023/03/21 15:03:11 &fmt.wrapError{msg:"uncaught error, initialize backend <sftp>, initialize backend, unable to get ssh auth method, unknown ssh method (PASSWORD, PUBLIC_KEY_FILE)", err:(*fmt.wrapError)(0xc000047280)}

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

bdebyl commented 1 year ago

The auth method isn't passed in via settings. Is this your .drone.yml file? If so, please update your .drone.yml block for drone-cache to look like this:

  image: meltwater/drone-cache:v1.4.0-linux-amd64
  pull: true
  environment:
    SFTP_HOST:
      from_secret: host
    SFTP_USERNAME:
      from_secret: sshname
    SFTP_AUTH_METHOD: PASSWORD
    SFTP_PASSWORD:
      from_secret: password
    SFTP_PORT: 22
    SFTP_CACHE_ROOT: /d/drone
  settings:
    backend: sftp
    restore: true
    debug: true
    volumes:
      - name: cache
        path: /drone

The settings you are attempting to use may not work the same way as the global options for the actual container. It is best to use environment variables in this case as shown above.