创建gitlab凭证,ssh类型,用户root,私钥贴进去,密码root密码,跑流水线的时候显示失败,没有输出日志
Jenkinsfile文件内容如下:
pipeline {
agent {
node {
label ‘base’
}
}
parameters {
string(name:'TAG_NAME',defaultValue: '',description:'')
}
environment {
DOCKER_CREDENTIAL_ID = 'harbor-id'
GITLAB_CREDENTIAL_ID = 'gitlab-id'
KUBECONFIG_CREDENTIAL_ID = 'kubeconfig-id'
REGISTRY = 'reg.xthklocal.cn'
HARBOR_NAMESPACE = 'xthk-online'
GITLAB_ACCOUNT = 'xthk-online'
APP_NAME = 'user-center-service-background'
PROJECT_GIT='user_center_service_background.git'
K8S_NAMESPACE='environment1'
}
stages {
stage ('checkout scm') {
steps {
checkout(scm)
}
}
stage('push with tag'){
when{
expression{
return params.TAG_NAME =~ /v.*/
}
}
steps {
container('base') {
input(id: 'release-image-with-tag', message: 'release image with tag?')
withCredentials([sshUserPrivateKey(credentialsId : 'gitlab-id' ,passwordVariable : 'GIT_PASSWORD' ,usernameVariable : 'GIT_USERNAME' ,)]) {
sh 'git config --global user.email "kubesphere@yunify.com" '
sh 'git config --global user.name "kubesphere" '
sh 'git tag -a $TAG_NAME -m "$TAG_NAME" '
sh 'git push git@gitlab.xthklocal.cn:$GITLAB_ACCOUNT/$PROJECT_GIT --tags --ipv4'
}
}
}
}
}
}