Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use JTE for declarative pipelines? #23

Closed
tkgreg opened this issue Sep 16, 2019 · 9 comments
Closed

Is it possible to use JTE for declarative pipelines? #23

tkgreg opened this issue Sep 16, 2019 · 9 comments

Comments

@tkgreg
Copy link

tkgreg commented Sep 16, 2019

No description provided.

@JugurthaT
Copy link

Have you found an answer for this?

@steven-terrana
Copy link

Hello @tkgreg and @JugurthaT - we have not extensively tested the use of the declarative syntax. as of now, it is not supported.

The issue is that declarative syntax expects to know what's going to happen before the pipeline runs, or be able to lookup steps that are contributed by regular jenkins shared libraries.

Due to the runtime composition of pipelines with JTE, they aren't natively compatible.

You could probably make your template a declarative pipeline and invoke steps from within a script block.

It might also be possible to use declarative syntax from within an individual library step but i have not tested this.

@Hokwang
Copy link

Hokwang commented May 12, 2020

@steven-terrana is there updates? did you test declarative syntax or do you have a plan for support?

@steven-terrana
Copy link

i have not tested JTE with declarative syntax.

I would love to be able to support but as of right now i'm not sure if it's even possible.

Currently working on a 2.0 release of JTE and can add declarative support as something I can at least look into.

no promises though :)

@tkgreg
Copy link
Author

tkgreg commented May 12, 2020

Can we take a look at the roadmap? :)

@steven-terrana
Copy link

i'm putting it together right now and i'll post a link at some point today on this issue!

give me an hour or so :)

@steven-terrana
Copy link

@Hokwang
Copy link

Hokwang commented May 14, 2020

@steven-terrana
I use below pipeline in most of cases.

pipeline {
	options {
		buildDiscarder(logRotator(daysToKeepStr: '90'))
		skipDefaultCheckout()
		timeout(time: 1, unit: 'HOURS')
		parallelsAlwaysFailFast()
		ansiColor('xterm')
// can vary 
	}
	
	triggers {
		pollSCM("* * * * *")
	}
	
	agent {
		kubernetes {
			yaml '''
// can vary for project or container
'''
		}
	}
	
	environment {
		// can vary
	}
	
	stages {
		stage('Sync') {
			steps {
				container(name: 'rhel7') { // name can vary
					checkout perforce(
                                        // can vary
					)
				}
			}
		}
		
		stage('Compile') {
			steps {
				container(name: 'rhel7', shell: '/bin/bash') { // can vary
					sh """
                                       // can vary
					"""
				}
			}
		}
		
		stage('Build Docker Image') {
			steps {
				container ('docker') {
					withCredentials([usernamePassword(credentialsId: "$DOCKER_REGISTRY_CREDENTIAL", usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASSWORD')]) {
						sh """
					       // maybe same 
						"""
					}
				}
			}
		}
		
		stage('Push Docker Image') {
			steps {
				container ('docker') {
					withCredentials([usernamePassword(credentialsId: "$DOCKER_REGISTRY_CREDENTIAL", usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASSWORD')]) {
						sh """
					      // maybe same
						"""
					}
				}
			}
		}
	}
	
	post {
		always {
			cleanup true
                       // can vary
		}
	}
}

In my org case,
I want to make/use template for
agent kubernetes syntax, (and env, options...)
each stages for project or container
and I want to declarative syntax.

Yet I didn't use template engine so don't know how it works and can be work for my thinkging
but I want to let you know this feature request.

Thanks,

@steven-terrana
Copy link

This functionality has been completed as part of #109 and an upstream PR in the declarative syntax plugin as part of corresponding pull request on jenkinsci/pipeline-model-definition-plugin#403.

This will be a part of the 2.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants