jenkins pipeline打tag
以下四种方式皆可用jenkins设置系统凭据方式一:pipeline {agent anystages {stage(‘test’) {steps {git credentialsId: ‘凭据id’, url:“http://git.name:git.password@git地址 "script{def GIT_TAG = new Date().format(“yyyyMMd...
以下四种方式皆可用
jenkins设置系统凭据
方式一:
pipeline {
agent any
stages {
stage(‘test’) {
steps {
git credentialsId: ‘凭据id’, url:“http://git.name:git.password@git地址 "
script{
def GIT_TAG = new Date().format(“yyyyMMddHHmmss”);
sh “””
git config user.email “your.email”
git config user.name “your.name”
git tag -a -m “${GIT_TAG}” ${GIT_TAG}
git push origin --tags
“”"
}
}
}
}
}
方式二:
Jenkins设置全局变量a=git.name, b=git.password
pipeline {
agent any
stages {
stage(‘test’) {
steps {
git credentialsId: ‘凭据id’, url:“http://
a
:
a:
a:b@git地址 "
script{
def GIT_TAG = new Date().format(“yyyyMMddHHmmss”);
sh “””
git config user.email “your.email”
git config user.name “your.name”
git tag -a -m “${GIT_TAG}” ${GIT_TAG}
git push origin --tags
“”"
}
}
}
}
}
方式三:
Jenkins设置凭据
pipeline {
agent any
options {
timeout(time:600, unit: ‘SECONDS’)
buildDiscarder(logRotator(numToKeepStr: ‘7’))
timestamps()
}
stages {
stage(‘test’) {
steps {
git credentialsId: ‘凭据id’, url: "git地址 "
withCredentials([[$class: ‘UsernamePasswordMultiBinding’, credentialsId: ‘凭据id’, usernameVariable: ‘GIT_USERNAME’, passwordVariable: ‘GIT_PASSWORD’]]) {
script{
def GIT_TAG = new Date().format(“yyyyMMddHHmmss”);
sh(“git config credential.username ${env.GIT_USERNAME}”)
sh(“git config credential.helper ‘!echo password=$GIT_PASSWORD; echo’”)
sh("git tag -a -m ‘${GIT_TAG}’ ${GIT_TAG} ")
sh(“git remote add origin git地址 || git push origin --tags”)
}
}
}
}
}
}
方式四:(ssh)
jenkins配置ssh凭据
pipeline {
agent any
environment {
target_branch = ‘master’
target_repo_url = ‘ssh地址’
git_auth_id = '凭据id'
}
stages {
stage(‘Hello’) {
steps {
// Pull code
script{
def GIT_TAG = new Date().format("yyyyMMddHHmmss");
git branch: env.target_branch, credentialsId: env.git_auth_id, url: env.target_repo_url
sh("git tag -a ${GIT_TAG} -m 'Jenkins'")
sh("git push origin ${GIT_TAG} --tags")
}
}
}
}
}
更多推荐
所有评论(0)