【问题标题】:Running CircleCI locally bitbucket & token error在本地运行 CircleCI bitbucket & token 错误
【发布时间】:2022-08-05 03:01:19
【问题描述】:

描述

运行这个:

$ circleci build --branch master --repo-url https://bitbucket.org/cityhive/city-hive-standalone-widget --job e2e

得到这些错误

Cloning into \'.\'...
Username for \'https://bitbucket.org\': fatal: could not read Username for \'https://bitbucket.org\': Success

...


# (from Jira orb)
/bin/bash: CIRCLE_TOKEN: Please provide a CircleCI API token for this orb to work!

如果我试图传递令牌,我会得到:

$ circleci build --token d14c4********* --branch master --repo-url https://bitbucket.org/cityhive/city-hive-standalone-widget --job e2e

Fetching latest build environment...
Docker image digest: sha256:7a080ca333******
WARNING: The requested image\'s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
Error: unknown flag: --token
ERRO[0000] Exit with status 1 due to generic error       error=\"unknown flag: --token\"

地点

https://circleci.com/docs/2.0/local-cli/#run-a-job-in-a-container-on-your-machine

重现步骤

运行检查代码并在本地本地拥有 JIRA orb 的作业

附加上下文

运行 macOS Monterey 12.3.1 (21E258),硅苹果芯片

码头工人:

$ docker version
Client:
 Cloud integration: v1.0.20
 Version:           20.10.10
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        b485636
 Built:             Mon Oct 25 07:43:15 2021
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.10
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       e2f740d
  Built:            Mon Oct 25 07:41:10 2021
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.4.11
  GitCommit:        5b46e404f6b9f661a205e28d59c982d3634148f8
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

配置.yml

version: 2.1
orbs:
  node: circleci/node@5.0.0
  jira: circleci/jira@1.3.1
  ruby: circleci/ruby@1.4.0

commands:
  ch-checkout:
    steps:
      # Instead of the default `checkout` phase that doesn\'t support depth.
      - run:
          name: \"Checkout Repository with --Depth 1\"
          command: |
              SSH_CONFIG_DIR=\"/home/circleci/.ssh\"
              mkdir -p \"$SSH_CONFIG_DIR\"
              chmod 0700 \"$SSH_CONFIG_DIR\"
              echo \"bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==\" >> \"$SSH_CONFIG_DIR/known_hosts\"
              chmod 0600 \"$SSH_CONFIG_DIR/known_hosts\"
              cd \'/home/circleci/myapp\'
              git clone --depth 1 \"$CIRCLE_REPOSITORY_URL\" --branch \"$CIRCLE_BRANCH\" .
      - run: ls -la ~/myapp/
  
  ch-install-compass:
    steps:
      - run:
          name: Install ruby
          command: |
            sudo apt update
            sudo apt install ruby-dev -y
            ruby -v
      - run:
          name: Install compass
          command: sudo gem install compass

  ch-ls:
    steps:
      - run:
          name: ls
          command: ls

  ch-widget-npm:
    steps:
     - node/install-packages

  ch-widget-bower:
    steps:
      - run:
          name: Widget - Install Deps (bower)
          command: npx bower install

  ch-widget-build:
    steps:
      - run:
          name: Widget - Build
          command: npx grunt build:prod

  ch-widget-test:
    steps:
      - run:
          name: Widget - Test
          command: |
              npx grunt build:dev
              # this only works by repeating it twice in the same step the test is invoked ????‍♀️
              Xvfb -s \"-nolisten tcp -nolisten unix\" -ac :99 -screen 0 1280x1024x16 &
              export DISPLAY=:99
              Xvfb -s \"-nolisten tcp -nolisten unix\" -ac :99 -screen 0 1280x1024x16 &
              export DISPLAY=:99
              npx karma start --browsers Chrome --single-run --env=ci --reporters dots
              npx karma start --browsers Chrome --single-run --loader-tests --env=ci --reporters dots

  ch-elements-npm:
    steps:
      - node/install-packages:
          app-dir: city-hive-custom-elements

  ch-elements-build:
    steps:
      - run:
          name: Custom Elements - Build
          command: cd city-hive-custom-elements/; npm run build

  ch-elements-test:
    steps:
      - run:
          name: Custom Elements - Tests
          command: |
              # this only works by repeating it twice in the same step the test is invoked ????‍♀️
              Xvfb -s \"-nolisten tcp -nolisten unix\" -ac :99 -screen 0 1280x1024x16 &
              export DISPLAY=:99
              Xvfb -s \"-nolisten tcp -nolisten unix\" -ac :99 -screen 0 1280x1024x16 &
              export DISPLAY=:99
              cd city-hive-custom-elements/; npm run test -- --watch=false
  
  ch-install-chrome:
    steps:
      - run:
          name: Install chrome deps
          command: sudo apt update && sudo apt install xdg-utils fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcairo2 libcups2 libgbm1 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libxdamage1 libxkbcommon0
      - run:
          name: Install chrome
          command: |
              wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
              sudo dpkg -i google-chrome-stable_current_amd64.deb

  ch-karma-deps:
    steps:
      - run:
          name: Karma - Deps
          command: |
              sudo apt-get install -y xvfb
  
  ch-spin-widget-dev:
    steps:
      - run:
          name: Spin Widget
          command: npx grunt serve:dev
          background: true

  ch-spin-elements-dev:
    steps:
      - run:
          name: Spin Custom Elements
          command: cd city-hive-custom-elements/; npm run serve
          background: true    

  ch-cypress-deps:
    steps:
      - run:
          name: Install Cypress deps
          command: sudo apt update && sudo apt install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
  
  ch-wait-for-servers:
    steps:
      - run:
          name: Wait for local servers
          command: |
            npx wait-on http://localhost:4200
            npx wait-on http://localhost:9003
  
  ch-cypress:
    steps:
      - run:
          name: Run Cypress tests
          no_output_timeout: 10m
          command: |
            mkdir ~/test_reports
            ./bin/ci_e2e
      - store_test_results:
          path: ~/test_reports
      - store_artifacts:
          path: ~/test_reports

jobs:
  build-widget:
    working_directory: ~/myapp
    docker:
      - image: cimg/node:16.13.1
    environment:
      # Enable colors in the output
      TERM: xterm
    steps:
      - ch-checkout
      - ch-install-compass
      - ch-widget-npm
      - ch-widget-bower
      - ch-widget-build

  test-widget:
    working_directory: ~/myapp
    docker:
      - image: cimg/node:16.13.1-browsers
    environment:
      # Enable colors in the output
      TERM: xterm
    steps:
      - ch-checkout
      - ch-install-compass
      - ch-widget-npm
      - ch-widget-bower
      - ch-install-chrome
      - ch-karma-deps
      - ch-widget-test

  build-elements:
    working_directory: ~/myapp
    docker:
      - image: cimg/node:16.13.1
    environment:
      # Enable colors in the output
      TERM: xterm
    steps:
      - ch-checkout
      - ch-elements-npm
      - ch-elements-build

  test-elements:
    working_directory: ~/myapp
    docker:
      - image: cimg/node:16.13.1-browsers
    environment:
      # Enable colors in the output
      TERM: xterm
    steps:
      - ch-checkout
      - ch-elements-npm
      - ch-elements-build
      - ch-install-chrome
      - ch-karma-deps
      - ch-elements-test

  e2e:
    working_directory: ~/myapp
    docker:
      - image: cimg/node:16.13.1-browsers
    resource_class: large
    environment:
      # Enable colors in the output
      TERM: xterm
    parallelism: 31
    steps:
      - ch-checkout
      - ch-install-compass
      - ch-widget-npm
      - ch-widget-bower
      - ch-elements-npm
      - ch-spin-widget-dev
      - ch-spin-elements-dev
      - ch-install-chrome
      - ch-cypress-deps
      - ch-wait-for-servers
      - ch-cypress

workflows:
  build-and-test:
    jobs:
      - build-widget:
          post-steps:
            - jira/notify
      
      - test-widget:
          post-steps:
            - jira/notify
      
      - build-elements:
          post-steps:
            - jira/notify
      
      - test-elements:
          post-steps:
            - jira/notify
      
      - e2e:
          post-steps:
            - jira/notify
  • 目前尚不清楚您为什么认为 --token 会从链接的文档中这样做。它所缺少的似乎更像是一个环境变量.你有[设置](circleci.com/docs/2.0/local-cli/#configuring-the-cli) CLI 吗?
  • --token 来自 circleci help build,是的,我进行了设置

标签: docker bitbucket circleci


【解决方案1】:

尝试改用 CIRCLECI_CLI_TOKEN 环境变量:

CIRCLECI_CLI_TOKEN=d14c4********* \ 
circleci build \
--branch master \
--repo-url https://bitbucket.org/cityhive/city-hive-standalone-widget \
--job e2e

【讨论】:

    【解决方案2】:

    @goldylucks,

    --token 标志是 CLI 设置的全局标志:

    --token 字符串你使用 CircleCI 的令牌,还有 CIRCLECI_CLI_TOKEN

    对于 Jira orb,需要 CircleCI API 令牌作为环境变量。

    查看circleci build -help 的输出,我看到:

    -e, --env -e VAR=VAL        Set environment variables, e.g. -e VAR=VAL
    

    这是您需要使用的标志,如CircleCI CLI documentation 中所述。

    【讨论】:

    • 不,这不起作用
    • 结果如何?你得到什么错误(如果有的话)?
    猜你喜欢
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 2022-10-24
    • 1970-01-01
    • 2013-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多