首页 > 解决方案 > 为什么没有使用 Jenkins 克隆 Bitbucket 源代码存储库?

问题描述

我在我的 Linux 机器中使用最新的 Jenkins。我正在尝试使用 Jenkins 管道克隆 Bitbucket 存储库和结帐主分支。我想要实现的是,在克隆了我的源代码之后,我可以利用它并继续构建。以下是我的代码;

node { 
    stage('Build') {

            git branch: 'master',
                credentialsId: '12345678-1234-1234-1234-123456789123',
                url: 'https://username@bitbucket.org/username/test.git'
    }
    stage('Test') {
        sh """pwd""" 
    }
}

下面是我的控制台输出;

Started by user User
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/test_pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] git
The recommended git tool is: NONE
using credential 12345678-1234-1234-1234-123456789123
 > git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/test_pipeline/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://username@bitbucket.org/username/test.git # timeout=10
Fetching upstream changes from https://username@bitbucket.org/username/test.git
 > git --version # timeout=10
 > git --version # 'git version 2.32.0'
using GIT_ASKPASS to set credentials bitbucket_token_1
 > git fetch --tags --force --progress -- https://username@bitbucket.org/username/test.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision ae8839d74d91d4ae28ba37a4ec91fa2265058b75 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f ae8839d74d91d4ae28ba37a4ec91fa2265058b75 # timeout=10
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D master # timeout=10
 > git checkout -b master ae8839d74d91d4ae28ba37a4ec91fa2265058b75 # timeout=10
Commit message: "Initial commit"
 > git rev-list --no-walk ae8839d74d91d4ae28ba37a4ec91fa2265058b75 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] sh
+ pwd
/var/lib/jenkins/workspace/test_pipeline
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

当我 cd 到时,/var/lib/jenkins/workspace/test_pipeline我什么也看不到。为什么会这样?

标签: jenkinsjenkins-pipeline

解决方案


推荐阅读