我有一個jenkins管道作業,其作業配置從回購中拉Jenkinsfile。一旦作業運行並拉出jenkins文件,它就克隆回購,並且我可以在作業區的工作區圖標中看到它。jenkins管道中的訪問工作區
現在,當我在Jenkinsfile中執行cd $ {workspace}和ls時,它不顯示任何內容。我如何訪問Jenkinsfile的回購工作區?或者它只是存儲Jenkinsfile本身?
這是我Jenkinsfile:
node ("master"){
// Mark the code checkout 'Checkout'....
stage 'Checkout'
sh "pwd ; ls"
}
當我運行它,我得到以下日誌:
> GitHub pull request #282 of commit
> 0045a729838aae0738966423ff19c250151ed636, no merge conflicts. Setting
> status of 0045a729838aae0738966423ff19c250151ed636 to PENDING with url
> https://10.146.84.103/job/test1/ and message: 'Pull request builder
> for this security group pr started' Using context: SG Terraform
> Validate/Plan
> > git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository
> > git config remote.origin.url https://github.xxx.net/Terraform/djin-sg/ # timeout=10 Fetching
> upstream changes from https://github.xxx.net/Terraform/djin-sg/
> > git --version # timeout=10 using GIT_ASKPASS to set credentials wsjbuild
> > git fetch --tags --progress https://github.xxx.net/Terraform/djin-sg/
> +refs/heads/*:refs/remotes/origin/*
> > git rev-parse origin/master^{commit} # timeout=10 Checking out Revision 9dd8491b7b18c47eac09cec5a4bff4f16df979bf (origin/master)
> > git config core.sparsecheckout # timeout=10
> > git checkout -f 9dd8491b7b18c47eac09cec5a4bff4f16df979bf First time build. Skipping changelog. [Pipeline] node Running on master in
> /var/lib/jenkins/workspace/test1 [Pipeline] { [Pipeline] stage
> (Checkout) Using the ‘stage’ step without a block argument is
> deprecated Entering stage Checkout Proceeding [Pipeline] wrap
> [Pipeline] { [Pipeline] sh [test1] Running shell script
> + cd /var/lib/jenkins/workspace/test1
> + ls
我的問題特別是把它克隆djin-SG回購的Jenkinsfile 。它也在工作區中。所以當我做ls爲什麼它不顯示文件?
當我去Jenkins作業流程步驟並在控制檯打開工作區時,我可以在工作區中看到完整的回購,但我似乎無法在作業中訪問它。
你想完成什麼?您能否以Jenkinsfile的形式發佈最低限度,完整且可驗證的示例(https://stackoverflow.com/help/mcve)? – burnettk
@burnettk - 請參閱編輯 – Scooby