[英]GitLab CI Pipeline: Pipeline cannot be run
我無法找出為什么我的 Repo 的 GitLab CI 管道無法運行。 我有一個.gitlab-ci.yml
文件並啟用了該功能,但管道不會運行。 此外,如果我嘗試手動觸發管道,我會返回以下錯誤。
Pipeline cannot be run.
Pipeline will not run for the selected trigger. The rules configuration prevented any jobs from being added to the pipeline.
CI 功能已啟用。
這是我的.gitlab-ci.yml
文件。
stages:
- build
- deploy
npm-run-build:
stage: build
image: node:19
only:
- main
cache:
key: ${CI_COMMIT_REF_SLUG}-build
paths:
- dist/
script:
- cp .env.example .env
- npm ci
- npm run build-only
deploy-dist:
stage: deploy
image: fedora:latest
only:
- main
environment:
name: production
url: https://example.com
needs:
- npm-run-build
cache:
key: ${CI_COMMIT_REF_SLUG}-build
paths:
- dist/
before_script:
- dnf install -y openssh-clients
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan -t rsa example.com > ~/.ssh/known_hosts
script:
# create remote project dir if not available
- ssh thomas@example.com "mkdir -p /home/thomas/example.com"
# upload project files
- scp -prq . thomas@example.com:/home/thomas/example.com
# restart the container
- ssh thomas@example.com "cd /home/thomas/example.com && docker-compose down && docker-compose up -d"
謝謝你!
正如 D Malan 在評論中指出的那樣,我將運行only
在main
分支上。 但是分支名其實是master
所以我只是將規則形式main
更改為master
現在它正在運行
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.