jenkinsci / jenkinsci/gitlab-plugin

Show stages in Gitlab, possible?

Open
#554 12 comments 11 reactions 0 assignees View on GitHub
feature request needs gitlab input
Dominant language
Java
Stars
1.4k
Forks
615
Avg merge
4h 32m
Merged PRs (30d)
10

Description

I'm testing out Jenkins declarative pipeline and I have a (multi-branch pipeline) job that builds successfully, however I would like it to show the stages in Gitlab, but I'm not sure how to do so (if it's even possible).

Here's what I mean:

I would like it to look something like this:

screen shot 2017-05-24 at 10 52 14 am

But so far, I get something like this:

screen shot 2017-05-24 at 10 52 42 am

This is my code so far:

```
#!/usr/bin/env groovy

// TEST FLAG - to make it easier to turn on/off unit tests for speeding up access to later stuff.
def runTests = true;
def testFlag = runTests ? '-Dmaven.test.failure.ignore=true' : '-DskipTests';

// Define common variables that will be used throughout this file.
def version() {
def matcher = readFile('pom.xml') =~ '(.+)'
matcher ? matcher[0][1] : null
}
// AAId = Application Artifact Id
def AAId() {
def matcher = readFile('pom.xml') =~ '(.+)'
matcher ? matcher[0][1] : null
}

def running(gitlabBuildName) {
updateGitlabCommitStatus(name: "${gitlabBuildName}", state: 'running')
}

def success(gitlabBuildName) {
updateGitlabCommitStatus(name: "${gitlabBuildName}", state: 'success')
}

def failure(gitlabBuildName) {
updateGitlabCommitStatus(name: "${gitlabBuildName}", state: 'failed')
}

properties ([
[$class: 'GitLabConnectionProperty', gitLabConnection: 'Gitlab'],
pipelineTriggers([[
$class: "GitLabPushTrigger",
triggerOnPush: true,
triggerOnMergeRequest: true,
// triggerOpenMergeRequestOnPush: "both",
// triggerOnNoteRequest: true,
// noteRegex: "REBUILD!",
// skipWorkInProgressMergeRequest: true,
// ciSkip: false,
// setBuildDescription: true,
// addNoteOnMergeRequest: true,
// addCiMessage: true,
// addVoteOnMergeRequest: true,
// acceptMergeRequestOnSuccess: true,
branchFilterType: "All",
// targetBranchRegex: "master",
// includeBranchesSpec: "master",
// excludeBranchesSpec: ""
]])
]);

pipeline {
// The following configures the GitLab connection and triggers the job on a push to GitLab.
agent any
options {
gitLabConnection('Gitlab');
timeout(time: 1, unit: 'HOURS'); // Time out for the pipeline
}

tools {
maven 'Maven 3.3.9'
}

environment {
APPLICATION_NAME = 'OrientDB Monitoring';
CREDENTIALS_ID = 'e379691b-fb37-4512-be0a-c246340e8b41';
MAVEN_NAME = 'Maven 3.3.9';
ORIENTDB_HOSTNAME = '10.96.15.0';
ORIENTDB_USER = 'user';
ORIENTDB_PASS = 'pass';
}

stages {
stage( 'Checkout SCM' ) {
agent {
node {
label 'jdk8-maven3'
}
}
options {
gitlabCommitStatus(name: 'Checkout');
}
steps {
checkout(changelog: true, poll: true,
scm: [$class: 'GitSCM', branches: [[name: '**']],//[[name: "origin/${env.gitlabSourceBranch}"]],
browser: [$class: 'GitLab', repoUrl: 'https://git.company.com', version: '9.1'],
doGenerateSubmoduleConfigurations: false,
// Delete workspace before the job starts.
extensions: [[$class: 'WipeWorkspace']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: "${CREDENTIALS_ID}",
name: 'origin', refspec: '+refs/pull/*:refs/remotes/origin/*',
url: 'git@git.covisintrnd.com:developer-services/sample-pipeline.git']]
}
}

// Now build the application.
stage( "Build application" ) {
agent {
node {
label 'jdk8-maven3'
}
}
steps {
gitlabBuilds(builds: ["Build", "Code quality"]) {
running('Build');
sh "mvn -Pdebug -U clean install ${testFlag} -V -B"
}
}
post {
success {
running('Code quality');
// Test code quality and send results to SonarQube.
withSonarQubeEnv('Sonar') {
sh "mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar"
}
success('Build');
success('Code quality');
}
failure {
failure('Build');
failure('Code quality');
}
}
}

// Run application to test it out.
stage("Test compiled application") {
agent {
node {
label 'jdk8-maven3'
}
}
steps {
script {
def appArtifactId = AAId()
def appVersion = version()
def workspace = pwd()
sh( "java -DHOSTNAME=${ORIENTDB_HOSTNAME} -DUSERID=${ORIENTDB_USER} -DPASSWORD=${ORIENTDB_PASS} -jar ${workspace}/target/${appArtifactId}-${appVersion}.jar" );
}
}
}
}
}
```

Any help is kindly appreciated!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.