0

I tried to upload all .js file from Gitlab-ci to Jfrog and I got this

curl: Can't open 'scripts/*.js'

It works if I point to a specified file (scripts/001.js)

My .gitlab-ci.yml

---
default:
  image:
    name: ubuntu:18.04
    entrypoint:
      - '/usr/bin/env'
      - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

stages:
  - upload

job01:
  only:
    - branches
  stage: upload
  script:
    - apt update -y
    - apt install curl -y
    - curl -u $JFROG_USERNAME:$JFROG_PASSWORD -X PUT $JFROG_URL -T 'scripts/*.js'

  tags:
    - runner-aws

I tried with 'scripts/(*).js' and the same error.

Franxi Hidro
  • 505
  • 4
  • 18

2 Answers2

1

The problem is that curl doesn't support wildcard character expansion in the -T option. This answer summarizes it nicely: https://unix.stackexchange.com/a/315431

So the solution would be to either enumerate multiple files like this:

   - curl -u $JFROG_USERNAME:$JFROG_PASSWORD -X PUT $JFROG_URL -T "scripts/{file1.js,file2.js,file3.js}"

But if there are too many files to enumerate, or the file names can change, you can use curl in combination with find (inspired by https://stackoverflow.com/a/14020013/7109330):

   - find scripts -type file -name "*.js" -exec curl -u $JFROG_USERNAME:$JFROG_PASSWORD -X PUT $JFROG_URL -T {} \;
bagljas
  • 791
  • 5
  • 16
0

I'd recommend using the JFrog CLI to upload files to Artifactory. It works much faster than curl by uploading files in parallel and avoiding uploading files that already exist in Artifactory.

It is also support wildcard patterns:

jfrog rt u "scripts/*.js" <path/in/artifactory> --user=$JFROG_USERNAME --password=$JFROG_PASSWORD --url=https://jfrog-platform-url/artifactory

Read more under Uploading Files.

yahavi
  • 5,149
  • 4
  • 23
  • 39