Tag a Repo from a Jenkins Workflow Script

后端 未结 5 612
孤城傲影
孤城傲影 2020-12-15 22:08

I\'m currently trying to tag a repo from a Jenkins Workflow script. I\'ve tried using a sh step but this runs into problems because of credentials not being set

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-15 22:13

    I've managed to get this working by using the withCredentials step provided by the credentials binding plugin.

    Its not great because it involved specifying it all in the URL but these values are masked in the console output.

    withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'MyID', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) {
    
        sh("git tag -a some_tag -m 'Jenkins'")
        sh("git push https://${env.GIT_USERNAME}:${env.GIT_PASSWORD}@ --tags")
    }
    

提交回复
热议问题