Skip to content
This repository was archived by the owner on Oct 5, 2018. It is now read-only.
This repository was archived by the owner on Oct 5, 2018. It is now read-only.

Authentication failing when attempting origin push when run inside a jenkins job #145

@bedge

Description

@bedge

I have a problem where my createReleaseBranch task works when I run it locally, but fails when run from a jenkins CI job.

Here's the output, note that createReleaseTag works fine, but my createReleaseBranch does not:

:workspace:createReleaseTag
Executing task ':createReleaseTag' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
Running [git, tag, -a, 3.50.0, -m, [Gradle Release Plugin] - creating tag:  '3.50.0'.] in [/u0/jenkins/jobs/CAS-admin-create-git-release/workspace]
Running [git, tag, -a, 3.50.0, -m, [Gradle Release Plugin] - creating tag:  '3.50.0'.] produced output: []
Running [git, remote] in [/u0/jenkins/jobs/CAS-admin-create-git-release/workspace]
Running [git, remote] produced output: []
Running [git, push, --porcelain, origin, 3.50.0] in [/u0/jenkins/jobs/CAS-admin-create-git-release/workspace]
Running [git, push, --porcelain, origin, 3.50.0] produced output: []
:createReleaseTag (Thread[main,5,main]) completed. Took 0.694 secs.
:createReleaseBranch (Thread[main,5,main]) started.
:workspace:createReleaseBranch
Executing task ':createReleaseBranch' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
release branch name = release/logan
The following authentication options are allowed (though they may not be available): [HARDCODED, SSHAGENT, INTERACTIVE, PAGEANT]
using interactive credentials, if needed
ssh-agent not available
pageant not available
jsch agent proxy not available

I'm hooking into this plugin in my own gradle script using:

updateVersion.dependsOn createReleaseBranch

where createReleaseBranch is:

task createReleaseBranch() {
    group = "Release"
    description = "Create branch (-Drelease.name=<name>) from current develop head"
    doLast {
        def release = System.getProperty("release.name")
        if (null == release) {
            throw new GradleException("-Drelease.name=.. missing.")
        }
        def releaseBranchName = "release/${release}"
        println "release branch name = ${releaseBranchName}"
        def repo = Grgit.open(project.file('.'))
        def branchService = repo.getBranch()
        def developBranch = branchService.getCurrent()
        def branchStatus
        try {
            branchStatus = branchService.getStatus(name: "release/${releaseBranchName}")
            throw new GradleException("Branch ${releaseBranchName} already exists.")
        }
        catch(Exception e) {}   // Expect that branch does not already exist.
        println "About to create branch"
        branchService.add(name: releaseBranchName, startPoint: 'develop', mode: BranchAddOp.Mode.TRACK)
        println "Branch created: ${releaseBranchName}, next push"
        try {
            repo.push(all: true)
            println "Push OK"
        }
        catch(Exception e) {
            // related to  https://github.com/allegro/axion-release-plugin/issues/66 ?
            println "Repo push failed, execute manually. This is usually needed from jenkins."
        }
    }
}

I want to create a branch from develop called release/XXX and push it to the origin.

Is there something I'm missing here?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions