相关疑难解决方法(0)

更改 jenkins 管道以使用 github 而不是 gitlab

我有一组在 jenkins 管道中运行的自动化测试,测试代码位于 gitlab 中。我从 gitlab 中提取代码的部分如下所示:

在此处输入图片说明

我使用那里已经存在的 gitlab 凭据(因为其他项目使用相同的 gitlab 凭据)。

我使用一个位于测试代码库中的简单 jenkinsfile 从这里运行脚本。大致是这样的:

  agent {
    kubernetes {
      defaultContainer 'jnlp'
      yaml """
        apiVersion: v1
        kind: Pod
        metadata:
          labels:
            application: auto_ish
        spec:
            containers:
              - name: node
                image: node:12.14.1
                command:
                - cat
                tty: true
      """
    }
  }
  stages {
    stage('Build') {
      steps {
        container('node') {
            sh '''
                npm install
            '''
        }
      }
    }

    stage('Test') {
      steps {
        container('node') {
          sh 'node_modules/.bin/wdio ./test/config/wdio.conf.acc.js --suite SmokeTest --mochaOpts.grep=@smoke' 
         }
      }
    }
Run Code Online (Sandbox Code Playgroud)

我的问题:

我的自动化测试的代码库最近移到了 github,我很难让它在 …

github jenkins

7
推荐指数
2
解决办法
5255
查看次数

Jenkins 多分支管道 GitHub 凭证不被接受

我正在尝试将我的 Jenkins 服务器与 github 项目链接起来。当使用 GitHub 作为源设置多分支管道作业并添加我的凭据时,出现以下错误:

Invalid credentials: https://api.github.com/user {"message":"Requires authentication","documentation_url":"https://docs.github.com/rest/reference/users#get-the-authenticated-user"}
Run Code Online (Sandbox Code Playgroud)

我检查了我的凭据,它们实际上是正确的。可能是什么问题呢?

在配置中,我添加了https://api.github.com作为 GitHub 服务器。在那里我检查了我的 GPAT 证书,它们有效。

在此输入图像描述

github jenkins

7
推荐指数
1
解决办法
5090
查看次数

Jenkins - Github 插件 - 使用个人访问令牌(2021 年 8 月 13 日更改后需要)

到目前为止,我们在 Jenkins 设置中使用的是带有用户名和密码凭据的 GitHub 插件。

但是,在 2021 年 8 月 13 日之后,此方法停止工作并引发此错误:

stderr: remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/了解更多信息。

根据如何在 Jenkins 中使用 Github 个人访问令牌中提供的答案

我将网址修改为:

https://<access token>@github.com/<userName>/<organization>/<repository>.git

但它不起作用。

我这里缺少任何步骤吗?

git authentication github jenkins jenkins-github-plugin

7
推荐指数
1
解决办法
2万
查看次数

使用 GitHub 配置 Jenkins(授权)

我想设置一个 Jenkins 来为一组从事不同项目的人构建 GitHub 项目,方式是项目在 Jenkins 中的可见性遵循 GitHub 中的授权。

我之前(成功)使用 GitHub Auth Plugin 和 Committer Strategy 完成了此操作,但无法重现配置。

我到目前为止所达到的:

  1. 我在 docker 中运行 jenkins/jenkins:jdk11。
  2. 我成功配置了 GitHub 身份验证,即用户通过 OAuth 进行身份验证(当前范围为“repo、read:org、read:user”),因此他们的 github 名称显示为用户名。

我添加了一些github项目,上次“GitHub Committer Strategy”帮我配置了可见性,但现在遇到了一个我不太明白的问题。

如果我将 GitHub 提交者策略的配置留空(管理员用户除外),经过身份验证的用户将看不到任何内容。有一条消息“访问被拒绝,XXX 缺少整体/读取权限”(已翻译)。

GitHub 提交者策略的选项

将选项留空时,每个经过身份验证的用户都会出错

当我选中“使用 GitHub 存储库权限”时,我仍然收到此错误。当我添加“向所有经过身份验证的用户授予 READ 权限”时,用户可以看到彼此的项目。

我什至不明白它应该如何工作。如何配置插件,以便每个经过身份验证的用户都能了解他所有项目的概况?

我正在使用 Jenkins 2.223 和 GitHub 身份验证插件 0.33。

oauth github jenkins

6
推荐指数
1
解决办法
2614
查看次数

Jenkins 中带有个人访问令牌的 Git 克隆永远空闲

我们有一个企业github运行在公司网络之外的远程github服务器上,需要使用https代理来克隆。我们不允许使用密码身份验证,因此要么使用 ssh(由于代理问题而无法使用)或 PAT。

在我的命令行上,命令

git clone https://user:token@github.exampleco.com/org/repo.git
Run Code Online (Sandbox Code Playgroud)

克隆存储库没有问题,大约需要 5-10 秒。

在 Jenkins 中,控制台输出显示“克隆到目录名称”,然后有一个旋转轮无休止地旋转,并且永远无法解决。

我在执行 shell 脚本中运行它,因为 github 插件运行一些命令,显然仍然想要进行密码身份验证,即使我向它提供没有凭据的 PAT 版本的 url,并且我没有看到 PAT 授权选项在添加凭据模式中。

为了澄清给 Jenkins 插件的 url 是:

https://user:token@github.exampleco.com/org/repo.git
Run Code Online (Sandbox Code Playgroud)

我得到这样的输出:

No credentials specified
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://user:token@github.exampleco.com/org/repo.git # timeout=10
Fetching upstream changes from https://user@github.exampleco.com/org/repo.git
 > git --version # timeout=10
Setting http proxy: corporateproxy.com:8080
 > git fetch --tags --progress https://user@github.exampleco.com/org/repo.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin' …
Run Code Online (Sandbox Code Playgroud)

git jenkins

2
推荐指数
1
解决办法
2万
查看次数

詹金斯管道Git Push

在Jenkinsfile中是否有这样的阶段:

stage('Create Branch & Push Branch') {
            steps {
                script {
                    sh "git checkout -b release/${NEW_TAG}"
                    sh "git push --set-upstream
                }
            }
    }
Run Code Online (Sandbox Code Playgroud)

目前,这导致:

  • git push --set-upstream原始版本/v1.0.3致命:无法读取“ https://github.com ”的用户名:没有此类设备或地址脚本返回退出代码128

该存储库最初是使用以下方式在管道中克隆的:

checkout poll: false, scm: [$class: 'GitSCM', branches: [[name: 'develop']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout'], [$class: 'CleanCheckout'], [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'ci-github', url: 'https://github.com/my-org/my-repo.git']]]
Run Code Online (Sandbox Code Playgroud)

该部分可以正常工作(克隆),大概是因为我可以为该步骤提供github的jenkins凭据ID。

我是否有办法做同样的事情来回溯到构建早期克隆的存储库?

git jenkins jenkins-pipeline

1
推荐指数
1
解决办法
7265
查看次数