我有一个主存储库,其中包含一个 NPM 包,该包加载另一个私有 NPM 包,这两个包位于 Gitlab 中的同一组织中。
我已经研究了几个小时,发现很多方法都行不通。首先是 Dockerfile,我认为它包含添加 SSH 密钥的最常见方法。
FROM node:10.15.1-alpine as image
WORKDIR /usr/src/app
RUN apk add --update --no-cache openssh git
COPY package.json ./
ARG SSH_PRIVATE_KEY
RUN mkdir /root/.ssh/ && \
echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa && \
chmod 600 /root/.ssh/id_rsa && \
touch /root/.ssh/known_hosts && \
ssh-keyscan gitlab.com > /root/.ssh/known_hosts
RUN npm install
FROM image as build
COPY . .
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait
CMD /wait && npm run start
EXPOSE 4000
Run Code Online (Sandbox Code Playgroud)
我通过以下方式调用它docker …
亲爱的 StackOverflow 社区,
我按照此(https://gitlab.com/help/ssh/README)指令创建了 ssh-keys。我将 ED25519 SSH 密钥对添加到网页上的 GitLab 配置文件中,如果我这样做,ssh -T git@gitlab.com我确实会收到消息Welcome to GitLab, @username!,到目前为止它似乎有效。
但是,我想git push从git pull本地存储库到 GitLab,而无需每次都输入密码。据我了解 SSH 密钥,这应该正是他们所做的,对吧?
编辑:
我的.ssh/config包含:
Host machine
User username
HostName machine.webside.com
Run Code Online (Sandbox Code Playgroud)
其中.gitconfig包含:
[user]
name = John Doe
email = john.doe@email.com
Run Code Online (Sandbox Code Playgroud)
并且.git/config包含:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://gitlab.com/johndoe/projectname.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = …Run Code Online (Sandbox Code Playgroud) 使用 gitlab-python 包,我想从所有 Dockerfile 中提取行。使用下面的代码,我可以获取项目名称和我想要的存储库的 url,但如何确保存在 Dockerfile 并读取 Dockerfile 的内容。
import gitlab
import json
from pprint import pprint
import requests
import urllib.request
# private token authentication
gl = gitlab.Gitlab('<path_to_gitlab_repo>', private_token=<token_here>)
gl.auth()
# list all projects
projects = gl.projects.list()
for project in projects:
# print(project) # prints all the meta data for the project
print("Project: ", project.name)
print("Gitlab URL: ", project.http_url_to_repo)
# print("Branches: ", project.repo_branches)
pprint(project.repository_tree(all=True))
f = urllib.request.urlopen(project.http_url_to_repo)
myfile = f.read()
print(myfile)
print("\n\n")
Run Code Online (Sandbox Code Playgroud)
我现在得到的输出是:
Gitlab URL: <path_to_gitlab_repo>
[{'id': '0c4a64925f5c129d33557',
'mode': …Run Code Online (Sandbox Code Playgroud) 如何配置 Composer 以使用 GitLab 实例的现有访问令牌?
在此期间,composer install我可能会收到一条警告,提示我需要访问令牌才能从 GitLab 实例中提取包。也许是因为该包是私有的或者我达到了 API 限制。然后,Composer 会要求输入用户名和密码,以启动 Gitlab 实例的 OAuth 进程并自行获取访问令牌。如果我没有用户名和密码,但已经有访问令牌怎么办?怎样设置才能让Composer下次使用呢?
我是 git 新手。我通读了一些命名约定,发现分支有不同的命名约定,如 hotfix/、bugfix/、feature/ 等。然而,这是我的第一个分支,我所做的只是更新自述文件,添加有关所需配置设置的注释。我应该如何命名这个分支?我相信这个小更新必须是一个分支,以便我可以在 gitlab 中提交合并请求。如果有任何有用的文档或者我的处理方法不正确,请告诉我。
我有 .gitlab-ci.yml 文件,其中包含作业(使用 Win Runner,但在我的问题中并不重要):
runWin:
stage: runOnWin
tags: ['WinRunner']
rules:
- if: $CI_COMMIT_BRANCH == $jobbranch
script: |
echo "WinRunner job started %CI_JOB_NAME%"
dir
Run Code Online (Sandbox Code Playgroud)
它工作正常,但是 gitlab-runner 从 git 下载源代码,但实际上我根本不需要它。我可以写一些命令或关键字来阻止它吗?
我有master和hotfix_master分支机构。这些是发布分支,并在项目设置下的 Gitlab UI 中受到保护。
我想要实现的是,hotfix_master在每次生产发布后重新调整分支master,这样如果客户提出任何错误,我们可以修复分支上的错误hotfix_master并向客户发布。
在进行概念验证时,我意识到即使hotfix_master分支受到保护,我仍然可以在不创建任何 PR 的情况下进行变基。这是预期的吗?如果是的话,保护有什么用?应该怎样做才能在创建 PR 后才允许变基?
编辑1
这就是我正在做的
- git fetch
- git checkout hotfix_master
- git diff --name-only origin/hotfix_master...origin/master
- git rebase origin/master
- git status
- git push
Run Code Online (Sandbox Code Playgroud)
变基后,我看到的是,所有更改master现在都已开始hotfix_master。那么,PR的问题在哪里呢?为什么 gitlab 没有抱怨你没有提高 PR 。请建议
编辑2
安装后,GitLab 在 Web 界面中需要登录名和密码。我没有安装它们,我对此无能为力,我也无法登录我的 gitlab,出现错误。
Invalid login or password.
Run Code Online (Sandbox Code Playgroud)
我已经准备好了下面的提交文件,然后将其与提交的其他文件一起git commit -F commitMessage.md推送到Gitlab 。
Apprentissage\n# Informatique\n\n - Documents re-r\xc3\xa9partis pour permettre d\'autres divisions\n - elk.md devient : `elk-01-installation-et-configuration`, `elk-02-elasticsearch`, `elk-03-logstash`, `elk-04-kibana`, `elk-05-filebeat-metricsbeat`.\n \n# Math\xc3\xa9matiques\n\n - Fonctions et applications >> `mathematiques-05-les-applications`\n\n# Statistiques\n\n - Documents re-r\xc3\xa9partis pour permettre d\'autres divisions\n - Les tests statistiques et hypoth\xc3\xa8ses >> `statistiques_05-les-tests-statistiques-et-hypotheses`\n - hypoth\xc3\xa8ses fortes et faibles (tests unilat\xc3\xa9ral ou bilat\xc3\xa9ral) >> `statistiques_05-les-tests-statistiques-et-hypotheses`\n - La comparaison d\'\xc3\xa9chantillons (par moyenne) >> `statistiques_06-la-comparaison-echantillons`\n - Probabilit\xc3\xa9s : passe du document 04 au `statistiques_40-les-probabilit\xc3\xa9s`\n\n# Territoire\n\n …Run Code Online (Sandbox Code Playgroud) gitlab ×10
git ×4
composer-php ×1
docker ×1
dockerfile ×1
git-rebase ×1
gitlab-api ×1
gitlab-ci ×1
node.js ×1
python ×1
ssh ×1
ssh-keys ×1
token ×1
ubuntu-18.04 ×1