jenkins - Jenkins Pipeline 失败但没有错误?
问题描述
我有以下管道脚本,它似乎在某些时候失败了。CredentialId 是正确的,github URL 是正确的,dotnet 的路径是正确的,而且我 99% 确定语法是正确的,因为输出(下面)正在正确读取我的脚本。所以,我只是想知道我是否做错了什么。
我以前从未使用过 Jenkins 或任何 CI/CD 工具,所以这对我来说是全新的。
我希望的目标是能够让Jenkins在每次与master合并时构建和运行一个.NET应用程序,但我只是想让它每小时成功构建,或者只是让它成功构建当我在 Jenkins 本身中单击立即构建时。
(另外,如果有一种简单的方法可以修改我的脚本以在每次主合并时运行,而不是每小时运行一次,那将非常有帮助!)
pipeline{
agent any
environment {
dotnet ='C:\\Program Files (x86)\\dotnet\\'
}
triggers {
pollSCM 'H * * * *'
}
stages{
stage('Checkout') {
steps {
git credentialsId: '0b02e39b-17f0-4628-ba3d-24146ec7a469', url: 'https://github.com/bellingboe/OktaKenkinsCI.git', branch: 'master'
}
}
stage('Restore packages'){
steps{
bat "dotnet restore C:\\Users\\Brenden\\Documents\\GitHub\\OktaKenkinsCI\\OktaKenkinsCI.csproj"
}
}
stage('Clean'){
steps{
bat "dotnet clean C:\\Users\\Brenden\\Documents\\GitHub\\OktaKenkinsCI\\OktaKenkinsCI.csproj"
}
}
stage('Build'){
steps{
bat "dotnet build C:\\Users\\Brenden\\Documents\\GitHub\\OktaKenkinsCI\\OktaKenkinsCI.csproj --configuration Releas'"
}
}
}
}
这给了我以下输出:
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\WINDOWS\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\JenkinsPipeline
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Checkout)
[Pipeline] git
The recommended git tool is: NONE
using credential 0b02e39b-17f0-4628-ba3d-24146ec7a469
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url https://github.com/bellingboe/OktaKenkinsCI.git # timeout=10
Fetching upstream changes from https://github.com/bellingboe/OktaKenkinsCI.git
> git.exe --version # timeout=10
> git --version # 'git version 2.29.2.windows.3'
using GIT_ASKPASS to set credentials
> git.exe fetch --tags --force --progress -- https://github.com/bellingboe/OktaKenkinsCI.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> git.exe rev-parse "origin/master^{commit}" # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Restore packages)
Stage "Restore packages" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Clean)
Stage "Clean" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
Stage "Build" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Finished: FAILURE
我的脚本中有什么错误吗?我真的不知道什么会失败,因为我根本没有看到任何错误。
解决方案
我想到了。我的主分支在 github 中被命名为“main”。
我有一个错字!
推荐阅读
- css - Bootstrap 似乎弄乱了我的导航栏
- c# - 将 NextResult 函数与 datareader 一起使用时出错
- javascript - 从 API 数据分配嵌套数组对象
- javascript - if 和 else 都在嵌套循环中执行
- youtube-api - 如何使用令牌从 2 个不同的 youtube 配置文件执行操作
- java - 将 JDO 项目迁移到谷歌云端点 v2,服务器返回 NoClassDefFoundError
- typescript - 将数组传递给 TypeScript 中的可变参数函数
- android - 带有 TabLayout 的片段内的 ScrollView 不滚动?
- ruby-on-rails - Ruby on Rails - 未初始化的常量 SiteController::API
- sapui5 - Northwind OData 服务不可用?