我正在尝试编写我的第一个管道脚本,我的想法如下。 我有一个主分支,我的两个团队将创建两个分支来完成主要分支。在两个独立的分支中提交之后,在触发构建之后,将开始一个作业将这两个分支合并到主分支。
这是我已经开始的管道脚本我尚未完成它:
pipeline {
agent any
stages {
stage ('Initialize') {
steps {
checkout changelog: true,
poll: true,
scm: [
$class: 'GitSCM',
branches: [[name: 'origin/master'], [name: 'origin/branch1'], [name: 'origin/branch2']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[
$class: 'PreBuildMerge',
options: [fastForwardMode: 'NO_FF',
mergeRemote: 'https://github.com/-----/jenkins.git',
mergeStrategy: 'org.jenkinsci.plugins.gitclient.MergeCommand.Strategy',
mergeTarget: 'master']
]
],
submoduleCfg: [],
userRemoteConfigs: [
[
credentialsId: '----------------',
name: 'origin',
url: 'https://github.com/------/jenkins.git'
]
]
]
}
}
stage ('Build') {
steps {
bat(/mvn clean package/)
}
post {
success {
junit 'target/surefire-reports/**/*.xml'
}
}
}
}
}
这是输出:
Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\shared-pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Initialize)
[Pipeline] checkout
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/------/jenkins.git # timeout=10
Fetching upstream changes from https://github.com/------/jenkins.git
git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
git.exe fetch --tags --progress https://github.com/------/jenkins.git +refs/heads/*:refs/remotes/origin/*
Seen branch in repository origin/branch1
Seen branch in repository origin/branch2
Seen branch in repository origin/master
Seen 3 remote branches
git.exe show-ref --tags -d # timeout=10
Merging Revision d466248662265f20ba50d752a6ca455314c (origin/branch1) to https://github.com/-----/jenkins.git/master, UserMergeOptions{mergeRemote='https://github.com/------/jenkins.git', mergeTarget='master', mergeStrategy='org.jenkinsci.plugins.gitclient.MergeCommand.Strategy', fastForwardMode='--no-ff'}
git.exe rev-parse "https://github.com/-------/jenkins.git/master^{commit}" # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
Stage 'Build' skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
hudson.plugins.git.GitException: Command "git.exe rev-parse "https://github.com/--------/jenkins.git/master^{commit}"" returned status code 128:
stdout: https://github.com/--------/jenkins.git/master^{commit}
stderr: fatal: Invalid object name 'https'.
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1996)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1964)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1960)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1597)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1609)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.revParse(CliGitAPIImpl.java:794)
at hudson.plugins.git.GitAPI.revParse(GitAPI.java:316)
at hudson.plugins.git.extensions.impl.PreBuildMerge.decorateRevisionToBuild(PreBuildMerge.java:66)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:1068)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1161)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:85)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:75)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Finished: FAILURE
提前感谢您的回复。