Re: 'Include' a shared library pipeline in other pipelines in the same shared library

2019-09-30 Thread Kaliyug Antagonist


*Note:*

   - The workspace(where the clone stag checks out the code and later 
   stages operate) will be used by awsPipeline etc. In other words, the 
   variables and results from the gradleProjectBranchWrapper should be 
   accessible to the awsPipeline etc.
   - There is a post block in the gradleProjectBranchWrapper, the other 
   pipelines may have their own post blocks


On Monday, September 30, 2019 at 9:35:30 AM UTC+2, Kaliyug Antagonist wrote:
>
> I have several microservices which use the same pipeline from a shared 
> library <https://jenkins.io/doc/book/pipeline/shared-libraries/> which is 
> named *jenkins-shared-pipelines* . The Jenkinsfile for a microservice is 
> as follows:
>
> @Library(['jenkins-shared-pipelines']) _
>
> gradleProjectPrPipeline([buildAgent: 'oc-docker-jdk11', 
> disableIntegrationTestStage: true])
>
> In jenkins-shared-pipelines/vars, the gradleProjectBranchWrapper has the 
> following stages:
>
> /**
>  * gradleProjectPrPipeline is a generic pipeline
>  * @param pipelineProperties map used to pass parameters
>  * @return
>  */
> void call(Map pipelineProperties = [:]) {
> .
> .
> .
>
> pipeline {
> agent {
> node {
> label "${pipelineProperties.buildAgent}"
> }
> }
>
> options {
> skipDefaultCheckout true
> timeout(time: 1, unit: 'HOURS')
> buildDiscarder(logRotator(
> numToKeepStr: '5',
> daysToKeepStr: '7',
> artifactNumToKeepStr: '1',
> artifactDaysToKeepStr: '7'
> ))
> }
>
> stages {
> stage('Clone') {
> steps {
> //clone step
> }
> }
> stage('Compile') {
> steps {
> script {
>/*Some custom logic*/
> }
> runGradleTask([task: 'assemble',
>rawArgs: defaultGradleArgs + " 
> -Pcurrent_version=${releaseTag}"
> ])
> }
> }
> stage('Tests') {
> parallel {
> stage('Unit tests') {
> steps {
> //Unit tests
> }
> }
> stage('Integration tests') {
> steps {
> //Integration tests
> }
> }
> }
> }
> stage('Sonar scan') {
> steps {
> //Sonar scanning
> }
> }
> }
>
> post {
>
> unsuccessful {
> script {
> bitbucketHandler.notifyBuildFail([
> displayName: pipelineName,
> displayMessage: "Build ${env.BUILD_ID} failed at 
> ${env.BUILD_TIMESTAMP}."
> ])
> }
> }
> success {
> script {
> bitbucketHandler.notifyBuildSuccess([
> displayName: pipelineName,
> displayMessage: "Build ${env.BUILD_ID} completed at 
> ${env.BUILD_TIMESTAMP}."
> ])
> }
> }
> }
> }
> }
>
> Now, there will be several more pipelines in 
> jenkins-shared-pipelines(under the same vars directory) e.g: awsPipeline, 
> azurePipeline and so on which will also incorporate the deployment stages. 
> These pipelines will require all the stages in the above 
> gradleProjectBranchWrapper and will also add a few of their own stages. 
> Currently, we simply copy-paste these stages in the new pipelines, then, we 
> invoke these new pipelines from the microservices, so for example:
>
> @Library(['jenkins-shared-pipelines']) _
>
> awsPipeline([buildAgent: 'oc-docker-jdk11', disableIntegrationTestStage: 
> true])
>
> I was wondering if there is a way to include the 
> gradleProjectBranchWrapper in the pipelines like awsPipeline, azurePipeline 
> and so on. Note: There is a post block in the gradleProjectBranchWrapper, 
> the other pipelines may have their own post blocks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/96537356-8976-4ef3-9327-e11b8be37e19%40googlegroups.com.


Re: 'Include' a shared library pipeline in other pipelines in the same shared library

2019-09-30 Thread Kaliyug Antagonist


On Monday, September 30, 2019 at 9:35:30 AM UTC+2, Kaliyug Antagonist wrote:
>
> I have several microservices which use the same pipeline from a shared 
> library <https://jenkins.io/doc/book/pipeline/shared-libraries/> which is 
> named *jenkins-shared-pipelines* . The Jenkinsfile for a microservice is 
> as follows:
>
> @Library(['jenkins-shared-pipelines']) _
>
> gradleProjectPrPipeline([buildAgent: 'oc-docker-jdk11', 
> disableIntegrationTestStage: true])
>
> In jenkins-shared-pipelines/vars, the gradleProjectBranchWrapper has the 
> following stages:
>
> /**
>  * gradleProjectPrPipeline is a generic pipeline
>  * @param pipelineProperties map used to pass parameters
>  * @return
>  */
> void call(Map pipelineProperties = [:]) {
> .
> .
> .
>
> pipeline {
> agent {
> node {
> label "${pipelineProperties.buildAgent}"
> }
> }
>
> options {
> skipDefaultCheckout true
> timeout(time: 1, unit: 'HOURS')
> buildDiscarder(logRotator(
> numToKeepStr: '5',
> daysToKeepStr: '7',
> artifactNumToKeepStr: '1',
> artifactDaysToKeepStr: '7'
> ))
> }
>
> stages {
> stage('Clone') {
> steps {
> //clone step
> }
> }
> stage('Compile') {
> steps {
> script {
>/*Some custom logic*/
> }
> runGradleTask([task: 'assemble',
>rawArgs: defaultGradleArgs + " 
> -Pcurrent_version=${releaseTag}"
> ])
> }
> }
> stage('Tests') {
> parallel {
> stage('Unit tests') {
> steps {
> //Unit tests
> }
> }
> stage('Integration tests') {
> steps {
> //Integration tests
> }
> }
> }
> }
> stage('Sonar scan') {
> steps {
> //Sonar scanning
> }
> }
> }
>
> post {
>
> unsuccessful {
> script {
> bitbucketHandler.notifyBuildFail([
> displayName: pipelineName,
> displayMessage: "Build ${env.BUILD_ID} failed at 
> ${env.BUILD_TIMESTAMP}."
> ])
> }
> }
> success {
> script {
> bitbucketHandler.notifyBuildSuccess([
> displayName: pipelineName,
> displayMessage: "Build ${env.BUILD_ID} completed at 
> ${env.BUILD_TIMESTAMP}."
> ])
> }
> }
> }
> }
> }
>
> Now, there will be several more pipelines in 
> jenkins-shared-pipelines(under the same vars directory) e.g: awsPipeline, 
> azurePipeline and so on which will also incorporate the deployment stages. 
> These pipelines will require all the stages in the above 
> gradleProjectBranchWrapper and will also add a few of their own stages. 
> Currently, we simply copy-paste these stages in the new pipelines, then, we 
> invoke these new pipelines from the microservices, so for example:
>
> @Library(['jenkins-shared-pipelines']) _
>
> awsPipeline([buildAgent: 'oc-docker-jdk11', disableIntegrationTestStage: 
> true])
>
> I was wondering if there is a way to include the 
> gradleProjectBranchWrapper in the pipelines like awsPipeline, azurePipeline 
> and so on. *Note:*
>
>- The workspace(where the clone stag checks out the code and later 
>stages operate) will be used by awsPipeline etc. In other words, the 
>variables and results from the gradleProjectBranchWrapper should be 
>accessible to the awsPipeline etc.
>- There is a post block in the gradleProjectBranchWrapper, the other 
>pipelines may have their own post blocks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/bdd51911-c3d3-459d-9434-f5d354bbcbf4%40googlegroups.com.


'Include' a shared library pipeline in other pipelines in the same shared library

2019-09-30 Thread Kaliyug Antagonist


I have several microservices which use the same pipeline from a shared 
library  which is 
named *jenkins-shared-pipelines* . The Jenkinsfile for a microservice is as 
follows:

@Library(['jenkins-shared-pipelines']) _

gradleProjectPrPipeline([buildAgent: 'oc-docker-jdk11', 
disableIntegrationTestStage: true])

In jenkins-shared-pipelines/vars, the gradleProjectBranchWrapper has the 
following stages:

/**
 * gradleProjectPrPipeline is a generic pipeline
 * @param pipelineProperties map used to pass parameters
 * @return
 */
void call(Map pipelineProperties = [:]) {
.
.
.

pipeline {
agent {
node {
label "${pipelineProperties.buildAgent}"
}
}

options {
skipDefaultCheckout true
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(
numToKeepStr: '5',
daysToKeepStr: '7',
artifactNumToKeepStr: '1',
artifactDaysToKeepStr: '7'
))
}

stages {
stage('Clone') {
steps {
//clone step
}
}
stage('Compile') {
steps {
script {
   /*Some custom logic*/
}
runGradleTask([task: 'assemble',
   rawArgs: defaultGradleArgs + " 
-Pcurrent_version=${releaseTag}"
])
}
}
stage('Tests') {
parallel {
stage('Unit tests') {
steps {
//Unit tests
}
}
stage('Integration tests') {
steps {
//Integration tests
}
}
}
}
stage('Sonar scan') {
steps {
//Sonar scanning
}
}
}

post {

unsuccessful {
script {
bitbucketHandler.notifyBuildFail([
displayName: pipelineName,
displayMessage: "Build ${env.BUILD_ID} failed at 
${env.BUILD_TIMESTAMP}."
])
}
}
success {
script {
bitbucketHandler.notifyBuildSuccess([
displayName: pipelineName,
displayMessage: "Build ${env.BUILD_ID} completed at 
${env.BUILD_TIMESTAMP}."
])
}
}
}
}
}

Now, there will be several more pipelines in jenkins-shared-pipelines(under 
the same vars directory) e.g: awsPipeline, azurePipeline and so on which 
will also incorporate the deployment stages. These pipelines will require 
all the stages in the above gradleProjectBranchWrapper and will also add a 
few of their own stages. Currently, we simply copy-paste these stages in 
the new pipelines, then, we invoke these new pipelines from the 
microservices, so for example:

@Library(['jenkins-shared-pipelines']) _

awsPipeline([buildAgent: 'oc-docker-jdk11', disableIntegrationTestStage: true])

I was wondering if there is a way to include the gradleProjectBranchWrapper 
in the pipelines like awsPipeline, azurePipeline and so on. Note: There is 
a post block in the gradleProjectBranchWrapper, the other pipelines may 
have their own post blocks

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/834dd15c-a3a0-4f2b-9ad4-9d85767b4dcc%40googlegroups.com.


Subscribe

2019-09-30 Thread Kaliyug Antagonist


-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAAGmGr8j3jp%3DHy2hq6Yneh6JoWf5tMe8_0D%3Dsh%2BEKOZ5wTCfyQ%40mail.gmail.com.


Is unit testing possible for classes using plugins

2019-03-11 Thread Kaliyug Antagonist


This class, to begin with, will have a generic, public httpRequest method:

/**
 * Provides Jenkins functionality required by the other utility classes.
 */
//Info: This class helps to reduce the Jenkins plug-in specific code clutter in 
the utility classes.
// All the Jenkins-specific code should be present in this(and more, if 
required) classes.
final class JenkinsUtil {

private def script

public JenkinsUtil(def script) {
this.script = script
}

/**
 *
 * @param link
 * @param parameters Refer the httpRequest plug-in https://jenkins.io/doc/pipeline/steps/http_request/;>documentation 
for acceptable parameters.
 * @return
 */
public def initiateHttpRequest(String link, Map parameters) 
{

//Remove
script.println "Link: ${link}, parameters: ${parameters}"

String validationErrorMessage = 
validateHttpRequestParameters(parameters)

if(validationErrorMessage != null && !validationErrorMessage.isEmpty()){
script.println "Validation error in httpRequest 
${validationErrorMessage}"
return validationErrorMessage
}

String parametersString = 
getAppendedParametersForHttpRequest(parameters)

script.httpRequest url: link,
parametersString
}

private String validateHttpRequestParameters(Mapparameters){

if(parameters == null || parameters.isEmpty()){
return "Parameters for the httpRequest cannot be null/empty."
}

//TODO:If the parameters contain anything other than the keys mentioned 
in the official documentation, return

//TODO:If the values for any of the parameter keys deviate from what 
the acceptable values as per the official documentation are, return
}

private String getAppendedParametersForHttpRequest(Map 
parameters){

StringBuffer parametersSb = new StringBuffer()

parameters.each{
key, value -> parametersSb << key+":"+value+","
}

parametersSb.deleteCharAt(parametersSb.length()-1)

//Remove
script.println "parameters are ${parametersSb.toString()}"
return parametersSb.toString()
}
}

Suppose, I try to write a unit test for the above class:

import spock.lang.Specification

class JenkinsUtilTest extends Specification {

def "InitiateHttpRequest"() {

given:
JenkinsUtil jenkinsUtil = new JenkinsUtil(/*How to create a script 
instance*/)
String url = "https://ci.prod-jenkins.com/cjoc/;
Mapparameters = new  HashMap<>()
parameters.put("ignoreSslErrors",true)

when:
def response = jenkinsUtil.initiateHttpRequest(url,parameters)

then:
response.contains("401")
}
}

}
}

Questions:

   1. How do I create a script instance to pass to the JenkinsUtil(Maybe, a 
   Expando or Script instance)
   2. Is there a way(say, by including some Jenkins dependencies in 
   build.gradle) to simulate the 'script.httpRequest' call i.e simulate the 
   Jenkins httpRequest plugin
   3. Is it correct to even think of unit-testing such a class
   4. Is it correct to even think of creating such a class
   

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/04b3f980-b59a-4b8a-86cd-7b55cf54ccea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: MissingMethodException while using shared libraries

2019-03-01 Thread Kaliyug Antagonist
Instantiating every time works well, I had tried that earlier but that 
isn't the way I wish to go :(

On Friday, March 1, 2019 at 9:20:09 AM UTC+1, Reinhold Füreder wrote:
>
> Hi,
>
>  
>
> a naive quick guess is that you are using too much groovy, but Jenkins 
> pipeline code is -- well -- not fully groovy…
>
>  
>
> => Maybe try to replace the fields like:
>
>  @Field final BitbucketBuildOperationsHandler bitbucketUtilities = 
> new BitbucketBuildOperationsHandler(this,env)
>
> … in “bitbucketUtilities.groovy” with explicitly instantiating it in each 
> method, e.g.:
>
> @NonCPS
>
> def notifyBuildFail(String message, String displayName) {
>
>  
>
> //Remove
>
> println "bitbucketUtilities global vars, env: "+env
>
>  
>
> validateCall(this, message, displayName)
>
>  
>
> BitbucketBuildOperationsHandler bitbucketUtilities = new 
> BitbucketBuildOperationsHandler(this,env)
>
> bitbucketUtilities.notifyBuildFail(message, displayName)
>
> }
>
>  
>
> Please also note that in @NonCPS annotated methods you may not call 
> pipeline steps AFAIK, “echo” step being a bit of an exception maybe?
>
>  
>
> HTH Reinhold
>
>  
>
> *From:* jenkins...@googlegroups.com  <
> jenkins...@googlegroups.com > *On Behalf Of *Kaliyug 
> Antagonist
> *Sent:* Freitag, 1. März 2019 08:51
> *To:* Jenkins Users >
> *Subject:* MissingMethodException while using shared libraries
>
>  
>
> Cloudbees 2.121.3.1
>
>  
>
> Partial Jenkinsfile of the main component that is failing viz. Alfaclient:
>
> properties([parameters([string(defaultValue: "", description: "List of 
> components", name: 'componentsToUpdate'),
>
> string(defaultValue: 
> "refs%2Fheads%2Fproject%2Fintegration", description: "BuildInfo CommitID", 
> name: 'commitId'),
>
> string(defaultValue: "", description: "Tag to 
> release, e.g. 1.1.0-integration", name: 'releaseTag'),
>
> string(defaultValue: "", description: "Forked 
> buildInfo repo. Be aware right commit ID!!!", name: 'fork')]),
>
> [$class: 'BuildDiscarderProperty', strategy: [$class: 
> 'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', 
> daysToKeepStr: '7', numToKeepStr: '5']],
>
> disableConcurrentBuilds()])
>
>  
>
> @Library(['jenkins-shared-utilities@integration/CICD-344-refactor-bitbucket-notify-handler','jenkins-shared-stages@integration/CICD-344-refactor-bitbucket-notify-handler','jenkins-shared-pipelines@integration/CICD-344-refactor-bitbucket-notify-handler'])
>  _
>
> .
>
> .
>
> .
>
> returnValue = componentPipeline {
>
> componentsToUpdate = rewriteDependencies
>
> commitId = buildInfoCommitId
>
> runOnForkedRepo = forkedRepo
>
> }
>
>  
>
> The componentPipeline in the above code is a scripted pipeline located in 
> vars of *jenkins-shared-pipelines* The partial Jenkinsfile(which doesn't 
> do much!) of jenkins-shared-pipelines
>
> #!groovy
>
>  
>
> @Library(['jenkins-shared-utilities@integration/CICD-344-refactor-bitbucket-notify-handler','jenkins-shared-stages@integration/CICD-344-refactor-bitbucket-notify-handler'])
>  _
>
>  
>
> Partial code for componentPipeline:
>
> def call(body) {
>
> def config = [:]
>
> body.resolveStrategy = Closure.DELEGATE_FIRST
>
> def componentName = null
>
> body.delegate = config
>
> body()
>
> def rewriteDependency = config.componentsToUpdate
>
> def buildInfoCommitId = config.commitId
>
> def forkedBuildInfo = config.runOnForkedRepo
>
>  
>
> def PIPELINE_NAME = "Component Pipeline"
>
> .
>
> .
>
> .
>
> setupSharedUtils(callingScript: this)
>
> .
>
> .
>
> .
>
> def build_status = "ok"
>
> stage(CLEAN_STAGE) {
>
> .
>
> .
>
> .
>
> bitbucketUtilities.notifyBuildStart("Build ${env.BUILD_ID} 
> started at ${env.BUILD_TIMESTAMP}", PIPELINE_NAME)
>
>  
>
> }
>
> stage(GET_BUILD_INFO) {
>
> .
>
> .
>
> .
>
> build_status = "${COMPILE_STAGE} failed in build ${env.BUILD_ID} 
> with exit code ${exit_code}"
>
> bitbucketUtilities.notifyBuildFail(build_status, PIPELINE_NAM

MissingMethodException while using shared libraries

2019-02-28 Thread Kaliyug Antagonist


Cloudbees 2.121.3.1


Partial Jenkinsfile of the main component that is failing viz. Alfaclient:

properties([parameters([string(defaultValue: "", description: "List of 
components", name: 'componentsToUpdate'),
string(defaultValue: 
"refs%2Fheads%2Fproject%2Fintegration", description: "BuildInfo CommitID", 
name: 'commitId'),
string(defaultValue: "", description: "Tag to release, 
e.g. 1.1.0-integration", name: 'releaseTag'),
string(defaultValue: "", description: "Forked buildInfo 
repo. Be aware right commit ID!!!", name: 'fork')]),
[$class: 'BuildDiscarderProperty', strategy: [$class: 
'LogRotator', artifactDaysToKeepStr: '', artifactNumToKeepStr: '', 
daysToKeepStr: '7', numToKeepStr: '5']],
disableConcurrentBuilds()])

@Library(['jenkins-shared-utilities@integration/CICD-344-refactor-bitbucket-notify-handler','jenkins-shared-stages@integration/CICD-344-refactor-bitbucket-notify-handler','jenkins-shared-pipelines@integration/CICD-344-refactor-bitbucket-notify-handler'])
 _
.
.
.
returnValue = componentPipeline {
componentsToUpdate = rewriteDependencies
commitId = buildInfoCommitId
runOnForkedRepo = forkedRepo
}


The componentPipeline in the above code is a scripted pipeline located in 
vars of *jenkins-shared-pipelines* The partial Jenkinsfile(which doesn't do 
much!) of jenkins-shared-pipelines

#!groovy

@Library(['jenkins-shared-utilities@integration/CICD-344-refactor-bitbucket-notify-handler','jenkins-shared-stages@integration/CICD-344-refactor-bitbucket-notify-handler'])
 _


Partial code for componentPipeline:

def call(body) {
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
def componentName = null
body.delegate = config
body()
def rewriteDependency = config.componentsToUpdate
def buildInfoCommitId = config.commitId
def forkedBuildInfo = config.runOnForkedRepo

def PIPELINE_NAME = "Component Pipeline"
.
.
.
setupSharedUtils(callingScript: this)
.
.
.
def build_status = "ok"
stage(CLEAN_STAGE) {
.
.
.
bitbucketUtilities.notifyBuildStart("Build ${env.BUILD_ID} started 
at ${env.BUILD_TIMESTAMP}", PIPELINE_NAME)

}
stage(GET_BUILD_INFO) {
.
.
.
build_status = "${COMPILE_STAGE} failed in build ${env.BUILD_ID} 
with exit code ${exit_code}"
bitbucketUtilities.notifyBuildFail(build_status, PIPELINE_NAME)

}   

}


Now comes the main library viz. *jenkins-shared-utilities*. It has the 
following structure: 


*vars* containing scripts that would act as global variables for components 
like *Alfaclient*.

bitbucketUtilities.groovy

import groovy.transform.Field
import com.jenkins.utilities.bitbucket.*
import com.cloudbees.groovy.cps.NonCPS

@Field final String STEP_NAME = getClass().getName()
@Field final BitbucketBuildOperationsHandler bitbucketUtilities = new 
BitbucketBuildOperationsHandler(this,env)

@NonCPS
def notifyBuildStart(String message, String displayName) {

//Remove
println "bitbucketUtilities global vars, env: "+env
validateCall(this, message, displayName)

bitbucketUtilities.notifyBuildStart(message, displayName)
}

@NonCPS
def notifyBuildSuccess(String message, String displayName) {

//Remove
println "bitbucketUtilities global vars, env: "+env

 validateCall(this, message, displayName)

bitbucketUtilities.notifyBuildSuccess(message, displayName)
}

@NonCPS
def notifyBuildFail(String message, String displayName) {

//Remove
println "bitbucketUtilities global vars, env: "+env

validateCall(this, message, displayName)

bitbucketUtilities.notifyBuildFail(message, displayName)
}

@NonCPS
private void validateCall(def script, String message, String displayName) {

if(message == null || message.isEmpty()) {
script.error("[ERROR][${script.STEP_NAME}] Build message not provided")
}

if(displayName == null || displayName.isEmpty()){
script.error("[ERROR][${script.STEP_NAME}] displayName not provided!")
}

}

setupSharedUtils.groovy

import groovy.transform.Field
import com.jenkins.utilities.ServiceLocator

void call(Map parameters = [:]) {
if (parameters?.callingScript == null) {
step.error(
"[ERROR][setupSharedUtils] No reference to surrounding script " +
"provided with key 'callingScript', e.g. 'callingScript: this'.")
} else {
parameters.callingScript.serviceLocator = ServiceLocator.getInstance()
}
}


*src* packages containing classes like BitbucketBuildOperationsHandler

class BitbucketBuildOperationsHandler implements  Serializable {

private def script
private def env
//TODO: Think if this should be an enum but iterating it will be an overhead
private static 

Re: EXTERNAL: Jenkins start-up fails after pointing to ssl cert and key

2017-11-27 Thread Kaliyug Antagonist
I can try that but is it mandatory to go that way? Can't Jenkins SSL work 
with the settings that I am using?

On Monday, November 27, 2017 at 11:28:09 AM UTC+1, Joaquin Henriquez wrote:
>
> Whats if you use NGINX as a reverse proxy …. That’s what I am doing (SSL) 
> and it is working fine.
>
>  
>
> *From:* jenkins...@googlegroups.com  [mailto:
> jenkins...@googlegroups.com ] *On Behalf Of *Kaliyug 
> Antagonist
> *Sent:* 27 November 2017 09:50
> *To:* Jenkins Users
> *Subject:* EXTERNAL: Jenkins start-up fails after pointing to ssl cert 
> and key
>
>  
>
>- Jenkins 2.73.3
>- Java(TM) SE Runtime Environment (build 1.8.0_151-b12) Java 
>HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
>- Red Hat Enterprise Linux Server release 7.4 (Maipo)
>
> The SSL cert and keys:
>
> [root@l5109p ssl]# ls -lrt /etc/security/ssl/
>
> -rw-r-. 1 jenkins jenkins  2894 Nov 27 09:17 
> jenkins_wildcard.sss.se.com.cert.pem
>
> -rw-r-. 1 jenkins jenkins  1766 Nov 27 09:18 
> jenkins_wildcard.sss.se.com.key.pem
>
> In the /etc/sysconfig/jenkins, I have added the following entry:
>
> JENKINS_ARGS="--httpsPort=8443 
> --httpsCertificate=/etc/security/ssl/jenkins_wildcard.sss.se.com.cert.pem 
> --httpsPrivateKey=/etc/security/ssl/jenkins_wildcard.sss.se.com.key.pem"
>
> On starting the jenkins service, it fails with the following error:
>
> Running from: /usr/lib/jenkins/jenkins.war
>
> Nov 27, 2017 9:42:17 AM Main deleteWinstoneTempContents
>
> WARNING: Failed to delete the temporary Winstone file 
> /tmp/winstone/jenkins.war
>
> Nov 27, 2017 9:42:17 AM org.eclipse.jetty.util.log.Log initialized
>
> INFO: Logging initialized @393ms to org.eclipse.jetty.util.log.JavaUtilLog
>
> Nov 27, 2017 9:42:17 AM winstone.Logger logInternal
>
> INFO: Beginning extraction from war file
>
> Nov 27, 2017 9:42:17 AM org.eclipse.jetty.server.handler.ContextHandler 
> setContextPath
>
> WARNING: Empty contextPath
>
> Nov 27, 2017 9:42:17 AM winstone.Logger logInternal
>
> INFO: Winstone shutdown successfully
>
> java.io.IOException: Failed to start a listener: 
> winstone.HttpsConnectorFactory
>
> at winstone.Launcher.spawnListener(Launcher.java:209)
>
> at winstone.Launcher.(Launcher.java:150)
>
> at winstone.Launcher.main(Launcher.java:354)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:498)
>
> at Main._main(Main.java:294)
>
> at Main.main(Main.java:132)
>
> Caused by: java.lang.IllegalArgumentException: Not B64 encoded
>
> at org.eclipse.jetty.util.B64Code.decode(B64Code.java:428)
>
> at org.eclipse.jetty.util.B64Code.decode(B64Code.java:391)
>
> at 
> winstone.AbstractSecuredConnectorFactory.readPEMRSAPrivateKey(AbstractSecuredConnectorFactory.java:131)
>
> at 
> winstone.AbstractSecuredConnectorFactory.configureSsl(AbstractSecuredConnectorFactory.java:75)
>
> at winstone.HttpsConnectorFactory.start(HttpsConnectorFactory.java:41)
>
> at winstone.Launcher.spawnListener(Launcher.java:207)
>
> ... 8 more
>
> Nov 27, 2017 9:42:17 AM winstone.Logger logInternal
>
> SEVERE: Container startup failed
>
> java.io.IOException: Failed to start a listener: 
> winstone.HttpsConnectorFactory
>
> at winstone.Launcher.spawnListener(Launcher.java:209)
>
> at winstone.Launcher.(Launcher.java:150)
>
> at winstone.Launcher.main(Launcher.java:354)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
> at java.lang.reflect.Method.invoke(Method.java:498)
>
> at Main._main(Main.java:294)
>
> at Main.main(Main.java:132)
>
> Caused by: java.lang.IllegalArgumentException: Not B64 encoded
>
> at org.eclipse.jetty.util.B64Code.decode(B64Code.java:428)
>
> at org.eclipse.jetty.util.B64Code.decode(B64Code.java:391)
>
> at 
> winstone.AbstractSecuredConnectorFactory.readPEMRSAPrivateKey(AbstractSecuredConnectorFactory.java:131)
>
> at 
> winstone.AbstractSecuredConnectorFactory.configureSsl(AbstractSecuredConnectorFactory.java:75)
>
&

Jenkins start-up fails after pointing to ssl cert and key

2017-11-27 Thread Kaliyug Antagonist

   
   - Jenkins 2.73.3
   - Java(TM) SE Runtime Environment (build 1.8.0_151-b12) Java HotSpot(TM) 
   64-Bit Server VM (build 25.151-b12, mixed mode)
   - Red Hat Enterprise Linux Server release 7.4 (Maipo)

The SSL cert and keys:

[root@l5109p ssl]# ls -lrt /etc/security/ssl/
-rw-r-. 1 jenkins jenkins  2894 Nov 27 09:17 
jenkins_wildcard.sss.se.com.cert.pem
-rw-r-. 1 jenkins jenkins  1766 Nov 27 09:18 
jenkins_wildcard.sss.se.com.key.pem

In the /etc/sysconfig/jenkins, I have added the following entry:

JENKINS_ARGS="--httpsPort=8443 
--httpsCertificate=/etc/security/ssl/jenkins_wildcard.sss.se.com.cert.pem 
--httpsPrivateKey=/etc/security/ssl/jenkins_wildcard.sss.se.com.key.pem"

On starting the jenkins service, it fails with the following error:

Running from: /usr/lib/jenkins/jenkins.war
Nov 27, 2017 9:42:17 AM Main deleteWinstoneTempContents
WARNING: Failed to delete the temporary Winstone file /tmp/winstone/jenkins.war
Nov 27, 2017 9:42:17 AM org.eclipse.jetty.util.log.Log initialized
INFO: Logging initialized @393ms to org.eclipse.jetty.util.log.JavaUtilLog
Nov 27, 2017 9:42:17 AM winstone.Logger logInternal
INFO: Beginning extraction from war file
Nov 27, 2017 9:42:17 AM org.eclipse.jetty.server.handler.ContextHandler 
setContextPath
WARNING: Empty contextPath
Nov 27, 2017 9:42:17 AM winstone.Logger logInternal
INFO: Winstone shutdown successfully
java.io.IOException: Failed to start a listener: winstone.HttpsConnectorFactory
at winstone.Launcher.spawnListener(Launcher.java:209)
at winstone.Launcher.(Launcher.java:150)
at winstone.Launcher.main(Launcher.java:354)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at Main._main(Main.java:294)
at Main.main(Main.java:132)
Caused by: java.lang.IllegalArgumentException: Not B64 encoded
at org.eclipse.jetty.util.B64Code.decode(B64Code.java:428)
at org.eclipse.jetty.util.B64Code.decode(B64Code.java:391)
at 
winstone.AbstractSecuredConnectorFactory.readPEMRSAPrivateKey(AbstractSecuredConnectorFactory.java:131)
at 
winstone.AbstractSecuredConnectorFactory.configureSsl(AbstractSecuredConnectorFactory.java:75)
at winstone.HttpsConnectorFactory.start(HttpsConnectorFactory.java:41)
at winstone.Launcher.spawnListener(Launcher.java:207)
... 8 more
Nov 27, 2017 9:42:17 AM winstone.Logger logInternal
SEVERE: Container startup failed
java.io.IOException: Failed to start a listener: winstone.HttpsConnectorFactory
at winstone.Launcher.spawnListener(Launcher.java:209)
at winstone.Launcher.(Launcher.java:150)
at winstone.Launcher.main(Launcher.java:354)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at Main._main(Main.java:294)
at Main.main(Main.java:132)
Caused by: java.lang.IllegalArgumentException: Not B64 encoded
at org.eclipse.jetty.util.B64Code.decode(B64Code.java:428)
at org.eclipse.jetty.util.B64Code.decode(B64Code.java:391)
at 
winstone.AbstractSecuredConnectorFactory.readPEMRSAPrivateKey(AbstractSecuredConnectorFactory.java:131)
at 
winstone.AbstractSecuredConnectorFactory.configureSsl(AbstractSecuredConnectorFactory.java:75)
at winstone.HttpsConnectorFactory.start(HttpsConnectorFactory.java:41)
at winstone.Launcher.spawnListener(Launcher.java:207)
... 8 more

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/d8802da2-4232-4e74-aad4-c04ef70f01ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.