the idea of this jenkins job is that it will receive a file as parameter and then this file must be push to github
This is the Jenkins Pipeline a have at the momento
pipeline {
agent {
label 'linux'
}
parameters {
file(
name:'file.yml',
description:'YAML file'
)
}
stages {
stage('github clone'){
steps {
git url: 'https://token@github.com/user/repo.git', branch: 'branch_name'
}
}
stage('push'){
steps {
sh 'git add folder/folder/${file.yml}'
sh 'git commit -m "upload new file" '
sh 'git push origin branch_name
}
}
}
}
and is given me this error
Started by user me
[Pipeline] Start of Pipeline
[Pipeline] node
Running on serverName in /home/jenkins/workspace/
[Pipeline] {
[Pipeline] stage
[Pipeline] { (github clone)
[Pipeline] git
The recommended git tool is: NONE
No credentials specified
Fetching changes from the remote Git repository
Checking out Revision 123456 (refs/remotes/origin/branch_name)
Commit message: ""
> git rev-parse --resolve-git-dir /home/jenkins/workspace/branch_name/.git # timeout=10
> git config remote.origin.url https://token@github.com/user/repo.git # timeout=10
Fetching upstream changes from https://token@github.com/user/repo.git
> git --version # timeout=10
> git --version # 'git version 2.25.1'
> git fetch --tags --force --progress -- https://token@github.com/user/repo.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/branch_name^{commit} # timeout=10
> git config core.sparsecheckout # timeout=10
> git checkout -f 123456 # timeout=10
> git branch -a -v --no-abbrev # timeout=10
> git branch -D branch_name # timeout=10
> git checkout -b branch_name 123456 # timeout=10
> git rev-list --no-walk 123456 1 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (push)
[Pipeline] sh
I already look this questions
Git push using jenkins credentials from declarative pipeline Is it possible to Git merge / push using Jenkins pipeline
What I'm expecting from the job is to upload the file successfully to github
Right now it fail at the beginning