Skip to content
Snippets Groups Projects
Select Git revision
  • dev/close
  • master default protected
  • amend_commit
  • next
  • dev/nomodifiable
  • dev/discard_vselect
  • dev/catch_shell_error
  • dev/mapping_2
  • dev/issue_123
  • dev/issue_71
  • dev/mapping
  • dev/remove_end_commit
  • dev/stash
  • dev/test_commit
  • dev/save_commmit_msg
  • dev/push
  • dev/git_diff
  • dev/undo
  • gh-pages
  • dev/display
  • 1.8.0
  • 1.7.3
  • 1.7.2
  • 1.7.1
  • 1.7.0
  • 1.6.0
  • 1.5.2
  • 1.5.1
  • 1.5.0
  • 1.4.2
  • 1.4.1
  • 1.4
  • 1.3
  • 1.2
  • 1.0
  • 1.1
36 results

Changelog

Blame
  • To find the state of this project's repository at the time of any of these versions, check out the tags.
    gitlab.go 915 B
    package condition
    
    import (
    	"fmt"
    	"os"
    )
    
    var CIVERSION = "dev"
    
    type GitLab struct {
    }
    
    func (gl *GitLab) Name() string {
    	return "GitLab CI"
    }
    
    func (gl *GitLab) Version() string {
    	return CIVERSION
    }
    
    func (gl *GitLab) GetCurrentBranch() string {
    	return os.Getenv("CI_COMMIT_BRANCH")
    }
    
    func (gl *GitLab) GetCurrentSHA() string {
    	return os.Getenv("CI_COMMIT_SHA")
    }
    
    func (gl *GitLab) IsBranchRef() bool {
    	return gl.GetCurrentBranch() != ""
    }
    
    func (gl *GitLab) RunCondition(config map[string]string) error {
    	defaultBranch := config["defaultBranch"]
    	if !gl.IsBranchRef() {
    		return fmt.Errorf("This test run is not running on a branch build.")
    	}
    	if branch := gl.GetCurrentBranch(); defaultBranch != "*" && branch != defaultBranch {
    		return fmt.Errorf("This test run was triggered on the branch %s, while semantic-release is configured to only publish from %s.", branch, defaultBranch)
    	}
    	return nil
    }