Giter VIP home page Giter VIP logo

jenkins-plugin's Introduction

OpenShift V3 Plugin for Jenkins

DEPRECATION NOTE: This plugin will only support OpenShift versions up to v3.11. Any OpenShift versions after that will require use of the OpenShift Client Plugin for Jenkins.

This project provides a series Jenkins plugin implementations that operate on Kubernetes based OpenShift. In summary they are a series of REST flows that interface with the OpenShift server via the exposed API. They minimally mimic the REST flows of common uses of the oc CLI command, but in several instances additional logic has been added to provide validation of the operations being performed.

Their ultimate intent is to provide easy to use building blocks that simplify the construction of the projects, workflows, and pipelines in Jenkins that operate against OpenShift deployments, where allowing OpenShift interactions via Jenkins build steps, pipeline DSL, etc. gives those familiar with Jenkins, but new to OpenShift and the oc CLI, a better introductory experience.

NOTE: This plugin does NOT require the oc binary be present.

NOTE: This plugin currently does not intend to match feature to feature what is provided via oc, but rather expose and augment when possible (additional validations for example) OpenShift API REST endpoints, with which the oc client also leverages, typically used with CI/CD type flows. One notable example of an oc option that is not exposed in the plugin is the oc new-app command. This omission stems from the fact that there is no single OpenShift server side API for oc new-app, and there is a fair amount of client side logic involved. Rather than invest in porting that logic to the plugin, we currently recommend that if oc new-app functionality is desired in your Jenkins jobs, either use the OpenShift Jenkins image, where the oc binary is already provided and can be invoked from your Jenkins jobs, or if you are not using the OpenShift Jenkins image, include the oc binary in your Jenkins installation.

NOTE: With the above two notes in mind, since this plugin was first envisioned and created, the rapid evolution of both Jenkins (including Pipelines and the introduction of Global Tool Configuration in Jenkins V2) and OpenShift have had an effect on how to best provide OpenShift integration from Jenkins jobs. The advantages of not requiring the oc binary to be included in the Jenkins path have been largely mitigated. The cost of porting oc REST interactions to Java is non-trivial. And the lack of functionality with client side logic in addition to REST flows, such as seen with oc new-app or binary builds, is more of a detriment.

To that end, starting with the 3.7 release of OpenShift, the OpenShift Client Plugin for Jenkins is now at GA status, fully supported, and is included in the OpenShift Jenkins images. The plugin is also available from the Jenkins Update Center. Envisioned as the long term direction for OpenShift integration from Jenkins jobs, among the features provided are:

  • A Fluent styled syntax for use in Jenkins Pipelines
  • Use of and exposure to any option available with oc
  • Integration with Jenkins Credentials and Clusters (more features which have solidified since this repository's plugin first arrived)
  • Continued support for classic Jenkins Freestyle jobs

Certainly feel free to continue and read about this plugin, but please check out the new plugin at your discretion. This plugin is still supported, and will continue to be included in the OpenShift Jenkins images. Consider it as being in maintenance mode, where no new features will be added.

NOTE: This plugin requires JDK 1.8, based on its maven dependency openshift-restclient-java.

The documentation and code at https://github.com/openshift/jenkins-plugin always hosts the very latest version, including possibly pre-released versions that are still under test. The associated repository under the JenkinsCI project, https://github.com/jenkinsci/openshift-pipeline-plugin, is only updated as part of cutting official releases of this plugin.

For each of those two repositories, this README represents the most technical and up to date description of this plugin's features. For reference, the associated wiki page for this plugin on the Jenkins site is here. The most important piece of information on that page will be the indication of the latest officially released version of this plugin.

Some Jenkins job examples which use this plugin and illustrate typical Jenkins / OpenShift integration flows can be found at:

And overall documentation for the OpenShift Jenkins image (which includes this plugin) is at:

Jenkins "build steps"

A series of Jenkins "build step" implementations are provided, which you can select from the Add build step pull down available on any project's configure page:

  1. "Trigger OpenShift Build": performs the equivalent of an oc start-build command invocation, where the build logs can be echoed to the Jenkins plugin screen output in real time; in addition to confirming whether the build succeeded or not, this build step can optionally look to see if any deployment configs have image change triggers for the image produced by the build config; if any such deployment configs are found, those deployments will be analyzed to see if they were triggered by an image change, comparing the image used by the currently running replication controller with the image used by its immediate predecessor.

  2. "Scale OpenShift Deployment": performs the equivalent of an oc scale command invocation; the number of desired replicas is specified as a parameter to this build step, and the plugin can optionally confirm whether the desired number of replicas was launched in a timely manner; if no integer is provided, it will assume 0 replica pods are desired.

  3. "Trigger OpenShift Deployment": performs the equivalent of an oc deploy --latest command invocation; it will monitor the resulting ReplicationController's "openshift.io/deployment.phase" annotation to confirm success.

  4. "Verify OpenShift Service": finds the ip and port for the specified OpenShift service, and attempts to make a HTTP connection to that ip/port combination to confirm the service is up.

  5. "Tag OpenShift Image": performs the equivalent of an oc tag command invocation in order to manipulate tags for images in OpenShift ImageStream's.

  6. "Verify OpenShift Deployment": determines whether the expected set of DeploymentConfig's, ReplicationController's, and if desired active replicas are present based on prior use of either the "Scale OpenShift Deployment" (2) or "Trigger OpenShift Deployment" (3) steps; its activities specifically include:

    • it first confirms the specified deployment config exists.
    • it then gets the list of all replication controllers for that DC, and determines which replication controller is the latest generation/incarnation of the deployment.
    • and then sees for the latest replication controller if a) the deployment phase annotation "openshift.io/deployment.phase" is marked as "Complete" within a (configurable) time interval, and then optionally b) if within a configurable time the current replica count is at least equal to the desired replica count.
    • NOTE: success with older incarnations of the replication controllers for a deployment is not sufficient for this Build Step; the state of the latest generation is what is verified.
    • NOTE: overriding of timeouts is detailed below.
  7. "Verify OpenShift Build": performs the equivalent of an 'oc get builds` command invocation for the provided build config key provided; once the list of builds are obtained, the state of the latest build is inspected to see if it has completed successfully within a reasonable time period; it will also employ the same deployment triggering on image change verification done in the "Trigger OpenShift Build" build step; this build step allows for monitoring of builds either generated internally or externally from the Jenkins Project configuration. NOTE: success or failure of older builds has no bearing; only the state of the latest build is examined.

  8. "Create OpenShift Resource(s)": performs the equivalent of an oc create command invocation; this build step takes in the provided JSON or YAML text, and if it conforms to OpenShift schema, creates whichever OpenShift resources are specified.

    • NOTE: if a namespace is specified in the provided json/yaml for any of the resources, that namespace will take precedence over the namespace specified in the "The name of the project to create the resources in" field. However, the authorization token provided in the field "The authorization token for interacting with OpenShift" must have edit permission to any project/namespace referenced in the json/yaml. If no token is specified, the assumption is that Jenkins in running in OpenShift, and the default service account associated with the project/namespace Jenkins is running in has edit permission to any project/namespace referenced in the json/yaml.
  9. "Delete OpenShift Resource(s)...": performs the equivalent of an oc delete command invocation; there are 3 versions of this build step; one takes in provided JSON or YAML text, and if it conforms to OpenShift schema, deletes whichever OpenShift resources are specified; the next form takes in comma delimited lists of types and keys, and deletes the corresponding entries; the last form takes in a comma separated list of types, along with comma separated lists of keys and values that might appear as labels on the API resources, and then for each of the types, deletes any objects that have labels that match the key/value pair(s) specified.

    • NOTE: if a namespace is specified in the provided json/yaml for any of the resources, that namespace will take precedence over the namespace specified in the "The name of the project to create the resources in" field. However, the authorization token provided in the field "The authorization token for interacting with OpenShift" must have edit permission to any project/namespace referenced in the json/yaml. If no token is specified, the assumption is that Jenkins in running in OpenShift, and the default service account associated with the project/namespace Jenkins is running in has edit permission to any project/namespace reference in the json/yaml.

Jenkins "Source Code Management (SCM)"

An implementation of the Jenkins SCM extension point is also provided that takes advantage of Jenkins' built in polling and version management capabilities, but within the context of OpenShift Image Streams (we have taken the liberty of broadening the scope of what is considered "source"):

  1. "OpenShift ImageStreams": the aforementioned baked-in polling mechanism provided by Jenkins is leveraged, exposing the common semantics between OpenShift ImageStreams (which are abstractions of Docker repositories) and SCMs; image IDs are maintained and treated like commit IDs for the requisite artifacts (images under the ImageStream instead of programmatic source files); when the image IDs for specific tags provided change (as reflected by updated "commit IDs" reported to Jenkins through the SCM plugin contract), Jenkins will initiate a build for the Project configuration in question; note, there are no "extractions" of any sort which leverage the workspaces provided by Jenkins to the SCMs. It is expected that the build steps in the associated project configuration will initiate any OpenShift related activities that were dependent on the ImageStream resource being monitored.

Jenkins "post-build actions"

A few Jenkins "post-build action" implementations are also provided, which you can select from the Add post-build action pull down available on any project's configure page:

  1. "Cancel OpenShift Builds": this action is intended to provide cleanup for a Jenkins project which failed because a build is hung (instead of terminating with a failure code); this step will allow you to perform the equivalent of a oc cancel-build for any builds found for the provided build config which are not previously terminated (either successfully or unsuccessfully) or cancelled; those builds will be cancelled.

  2. "Cancel OpenShift Deployment": this action is intended to cleanup any OpenShift deployments which still in-progress after the Build completes; this step will allow you to perform the equivalent of a oc deploy --cancel for the provided deployment config.

  3. "Scale OpenShift Deployment": performs the equivalent of an oc scale command invocation; the number of desired replicas is specified as a parameter to this build step, and the plugin can optionally confirm whether the desired number of replicas was launched in a timely manner; if no integer is provided, it will assume 0 replica pods are desired. And yes, it is equivalent to the "Scale OpenShift Deployment" build step listed above.

Jenkins Pipeline (formerly Workflow) Plugin

DSL

Starting with version 1.0.14 of the OpenShift Pipeline Plugin, the "build steps" are now accessible via the Jenkins Pipeline Plugin Step API for creating DSL extensions for the Pipeline Plugin. This Pipeline DSL is the replacement for the Java object instantiation within the Pipeline Groovy scripts noted below.

For each of the DSLs, you can still instantiate the various steps and assign to a variable, however you no longer need to pass it to the step method (execution will commence immediately after the step is created). This is shown in the following example:

def builder = openshiftBuild buildConfig: 'frontend'

NOTE: the Pipeline Plugin "Snippet Generator" creates Groovy of this form.

You can also create the step without assigning it to a variable and allow the automatic execution to commence. This is shown in the following example:

openshiftBuild(buildConfig: 'frontend')

Here is the complete DSL reference for the OpenShift Pipeline Plugin.

Optional parameters that apply to all the DSL steps:

  • "apiURL": URL of the OpenShift api endpoint. If nothing is specified, the plugin will inspect the KUBERNETES_SERVICE_HOST environment variable. If that variable is not set, the plugin will attempt to connect to "https://openshift.default.svc.cluster.local".
  • "namespace": The name of the project the BuildConfig is stored in. If nothing is specified, the plugin will inspect the PROJECT_NAME environment variable.
  • "authToken": The authorization token for interacting with OpenShift. If you do not supply a value, the plugin will assume it is running in the OpenShift Jenkins image and attempt to load the kubernetes service account token stored in that image.
  • "verbose": Allow for verbose logging during this build step plug-in. Set to true to generate the additional logging.

"Trigger OpenShift Build"

The step name is "openshiftBuild". Mandatory parameters are:

  • "buildConfig" or "bldCfg": The name of the BuildConfig to trigger. NOTE: both names work with scripted pipelines, but only "bldCfg" works with declarative pipelines.

Optional parameters are:

  • "buildName": The name of a previous build which should be re-run. Equivalent to specifying the --from-build option when invoking the OpenShift oc start-build command.
  • "commitID": The commit hash the build should be run from. Equivalent to specifying the --commit option when invoking the OpenShift oc start-build command.
  • "env": An array of environment variables for the build (e.g. env : [ [ name : 'name1', value : 'value1' ], [ name : 'name2', value : 'value2' ] ].
  • "showBuildLogs": Pipe the build logs from OpenShift to the Jenkins console.
  • "checkForTriggeredDeployments": Verify whether any deployments triggered by this build's output fired.
  • "waitTime": Time in milliseconds to wait for build completion. Default is 15 minutes.

"Trigger OpenShift Deployment"

The step name is "openshiftDeploy". Mandatory parameters are:

  • "deploymentConfig" or "depCfg": The name of the DeploymentConfig to trigger. NOTE: both names work with scripted pipelines, but only "depCfg" works with declarative pipelines.

Optional parameters are:

  • "waitTime": Time in milliseconds to wait for deployment completion. Default is 10 minutes.

"Run OpenShift Exec"

The step name is "openshiftExec". Mandatory parameters are:

  • "pod" : The name of the pod in which to execute the command.
  • "command" : The name of the command to run. May be specified as command: '/usr/bin/echo' or in a compact form including parameters as command: [ '/usr/bin/echo', 'hello', 'world', ... ]

Optional parameters are:

  • "container" : The container name in which to run the command. If not specified, the first container in the pod will be used.
  • "arguments" : Arguments for the command. May be specified as arguments: [ 'arg1', 'arg2', ... ] or arguments: [ [ value: 'arg1' ], [ value : 'arg2' ], ... ]
  • "waitTime" : Time in milliseconds to wait for deployment completion. Default is 3 minutes.

The object returned exposes the following attributes:

  • stdout : All standard out received from the exec API.
  • stderr : All standard error received from the exec API.
  • error : A string describing any execution errors from the exec API (e.g. command not found in pod PATH).
  • failure : A string describing any low level failure to execute the exec API (e.g. protocol level errors).

All attributes are empty strings by default. As the exec API delivers messages (e.g. individual lines of standard output), each message will be appended to the respective result attribute and followed by a linefeed.

    def response = openshiftExec( ... command: 'echo', arguments : [ 'hello', 'world' ] ... )
    if ( response.error == "" && response.failure == "" ) {
        println('Stdout: '+response.stdout.trim())
        println('Stderr: '+response.stderr.trim())
    } else {
        ...
    }
    

It should be evident from the above example that "errors" and "failures" returned by the Exec API are exposed to the caller by the response object and do not, therefore, terminate the Jenkins build. This allows the caller to programmatically handle some failure conditions.

Other failure conditions where the API cannot be executed or its result ascertained (timeouts or an inability to find the specified Pod) will be treated as fatal errors and terminate the Jenkins build with an error.

When used as a step in a Freestyle job, the Exec operation does not distinguish between these categories of failure. Since outcomes cannot be handled programmatically in a freestyle job, all failures will result in the termination of the Jenkins build.

"Create OpenShift Resource(s)"

The step name is "openshiftCreateResource". Mandatory parameters is either:

  • "json", "yaml", or "jsonyaml": The JSON or YAML representation of the OpenShift resources. Note, the plugin does not care if YAML is provided under the "json" key or vice-versa. As long as the string passes either the JSON or YAML format checking, it will be processed. NOTE: all these names work with scripted pipelines, but only "jsonyaml" works with declarative pipelines.

"Delete OpenShift Resource(s) from JSON/YAML"

The step name is "openshiftDeleteResourceByJsonYaml". Mandatory parameters is either:

  • "json", "yaml", or "jsonyaml": The JSON or YAML representation of the OpenShift resources. Note, the plugin does not care if YAML is provided under the "json" key or vice-versa. As long as the string passes either the JSON or YAML format checking, it will be processed. NOTE: all these names work with scripted pipelines, but only "jsonyaml" works with declarative pipelines.

"Delete OpenShift Resource(s) using Labels"

The step name is "openshiftDeleteResourceByLabels". Mandatory parameters are:

  • "types": The type(s) of OpenShift resource(s) to delete. Provide a comma-separated list.

  • "keys": The key(s) of labels on the OpenShift resource(s) to delete. Provide a comma-separated list.

  • "values": The value(s) of labels on the OpenShift resource(s) to delete. Provide a comma-separated list.

"Delete OpenShift Resource(s) by Key"

The step name is "openshiftDeleteResourceByKey". Mandatory parameters are:

  • "types": The type(s) of OpenShift resource(s) to delete. Provide a comma-separated list.

  • "keys": The key(s) of the OpenShift resource(s) to delete. Provide a comma-separated list.

"Scale OpenShift Deployment"

The step name is "openshiftScale". Mandatory parameters are:

  • "deploymentConfig" or "depCfg": The name of the DeploymentConfig to scale. NOTE: both names work with scripted pipelines, but only "depCfg" works with declarative pipelines.

  • "replicaCount": The number of replicas to scale to.

Optional parameters are:

  • "verifyReplicaCount": Verify whether the specified number of replicas are up. Specify true or false.

  • "waitTime": The amount of time in milliseconds to see whether the specified number of replicas have been reached. Default is 3 minutes.

"Tag OpenShift Image"

The step name is "openshiftTag". Mandatory parameters are:

  • "sourceStream" or "srcStream": The ImageStream of the existing image. NOTE: all these names work with scripted pipelines, but only "srcStream" works with declarative pipelines.

  • "sourceTag" or "srcTag": The tag (ImageStreamTag type) or ID (ImageStreamImage type) of the existing image. NOTE: all these names work with scripted pipelines, but only "srcTag" works with declarative pipelines.

  • "destinationStream" or "destStream": The ImageStream for the new tag. A comma delimited list can be specified. NOTE: all these names work with scripted pipelines, but only "destStream" works with declarative pipelines.

  • "destinationTag" or "destTag": The name of the new tag. A comma delimited list can be specified. NOTE: all these names work with scripted pipelines, but only "destTag" works with declarative pipelines.

    The following combinations are supported:

    1. 1 destination stream and 1 destination tag (i.e. single tag applies to single stream)
      • destinationStream: 'stream1', destinationTag: 'tag1'
    2. 1 destination stream and N destination tags (i.e. all tags apply to the same stream)
      • destinationStream: 'stream1', destinationTag: 'tag1, tag2'
    3. 1 destination tag and N destination streams (i.e. all streams will get the same tag)
      • destinationStream: 'stream1, stream2', destinationTag: 'tag1'
    4. N destination streams and N destination tags (i.e. each index will be combined to form a unique stream:tag combination)
      • destinationStream: 'stream1, stream2', destinationTag: 'tag1, tag2'

Optional parameters are:

  • "namespace" : Namespace of the source ImageStream (If Jenkins is running within OpenShift, defaults to the namespace in which Jenkins is running).

  • "alias": Whether to update destination tag whenever the source tag changes. Equivalent of the --alias option for the oc tag command. When false, the destination tag type is "ImageStreamImage", and when true, the destination tag type is "ImageStreamTag".

  • "destinationNamespace": The name of the project to host the destinationStream:destinationTag. If nothing is specified, the plugin will use the source namespace.

  • "destinationAuthToken": The authorization token for interacting with the destinationNamespace. If you do not supply a value, the plugin will assume it is running in the OpenShift Jenkins image and attempt to load the kubernetes service account token stored in that image.

"Verify OpenShift Build"

The step name is "openshiftVerifyBuild". Mandatory parameters are:

  • "buildConfig" or "bldCfg": The name of the BuildConfig to verify. NOTE: both names work with scripted pipelines, but only "bldCfg" works with declarative pipelines.

Optional parameters are:

  • "checkForTriggeredDeployments": Verify whether any deployments triggered by this build's output fired.
  • "waitTime": Time in milliseconds to wait for build completion. Default is 1 minute.

"Verify OpenShift Deployment"

The step name is "openshiftVerifyDeployment". Mandatory parameters are:

  • "deploymentConfig" or "depCfg": The name of the DeploymentConfig to scale. NOTE: both names work with scripted pipelines, but only "depCfg" works with declarative pipelines.

Optional parameters are:

  • "replicaCount": The number of replicas to scale to.

  • "verifyReplicaCount": Verify whether the specified number of replicas are up. Specify true or false.

  • "waitTime": The amount of time in milliseconds to see whether the specified number of replicas have been reached. Default is 3 minutes.

"Verify OpenShift Service"

The step name is "openshiftVerifyService". Mandatory parameters are:

  • "serviceName" or "svcName": The name of the service to connect to. NOTE: both names work with scripted pipelines, but only "svcName" works with declarative pipelines.

Optional parameters are:

  • "retryCount": The number of times to attempt a connection before giving up. The default is 100.

"ImageStreams SCM"

This step associates a pipeline with an ImageStream as its SCM. With polling enabled on a job, this allows a pipeline job to be launched automatically whenever a new image is tagged on an ImageStream.

NOTE: with the advent of OpenShift Pipeline Build Strategy, incorporating your pipeline into such a BuildConfig along with the use of an Image Change Trigger is the better choice for triggering pipeline jobs from changes to ImageStreams in OpenShift.

The step name is "openshiftImageStream". Mandatory parameters are:

  • "name": The name of the ImageStream to poll

  • "tag": The tag to watch on the ImageStream

  • "namespace": The project for the ImageStream

Pipeline / Workflow support prior to version 1.0.14 of the OpenShift Pipeline Plugin

Each of the Jenkins "build steps" can also be used as steps in a Jenkins Pipeline / Workflow plugin Groovy script, as they implement jenkins.tasks.SimpleBuildStep and java.io.Serializable. From your Groovy script, instantiate the associated Java object, and then leverage the workflow plugin step keyword to call out to the object with the necessary workflow contexts. Here is a useful reference on constructing Jenkins Workflow Groovy scripts.

As a point of reference, here are the Java classes for each of the Jenkins "build steps":

  1. "Trigger OpenShift Build": com.openshift.jenkins.plugins.pipeline.OpenShiftBuilder

  2. "Scale OpenShift Deployment": com.openshift.jenkins.plugins.pipeline.OpenShiftScaler

  3. "Trigger OpenShift Deployment": com.openshift.jenkins.plugins.pipeline.OpenShiftDeployer

  4. "Verify OpenShift Service": com.openshift.jenkins.plugins.pipeline.OpenShiftServiceVerifier

  5. "Tag OpenShift Image": com.openshift.jenkins.plugins.pipeline.OpenShiftImageTagger

  6. "Verify OpenShift Deployment": com.openshift.jenkins.plugins.pipeline.OpenShiftDeploymentVerifier

  7. "Verify OpenShift Build": com.openshift.jenkins.plugins.pipeline.OpenShiftBuildVerifier

  8. "Create OpenShift Resource(s)": com.openshift.jenkins.plugins.pipeline.OpenShiftCreator

  9. "Delete OpenShift Resource(s)...": com.openshift.jenkins.plugins.pipeline.OpenShiftDeleterJsonYaml, com.openshift.jenkins.plugins.pipeline.OpenShiftDeleterList, com.openshift.jenkins.plugins.pipeline.OpenShiftDeleterLabels

Common aspects across the REST based functions (build steps, SCM, post-build actions)

Authorization

In order for this plugin to operate against OpenShift resources, the OpenShift service account for the project(s) being operated against will need to have the necessary role and permissions. In particular, you will need to add the edit role to the service account in the project those resources are located in.

For example, in the case of the test project, the specific command will be: oc policy add-role-to-user edit system:serviceaccount:test:<service account name>

If that project is also where Jenkins is running out of, and hence you are using the OpenShift Jenkins image (https://github.com/openshift/jenkins), then the bearer authorization token associated with that service account is already made available to the plugin (mounted into the container Jenkins is running in at "/run/secrets/kubernetes.io/serviceaccount/token"). So you don't need to specify it in the various build step config panels.

Next, in the case of "Tag OpenShift Image", you could potentially wish to access two projects (the source and destination image streams can be in different projects with oc tag). If so, then either the service account token which Jenkins is running under, the "source" token, needs edit access to both projects, or you need to supply an additional token (most likely a service account in the second project) with edit access to the second/destination project and at least view access to the first/source project.

Consider the scenario where the source image stream is in the project test and the destination image stream is in project test2. Then try these two commands:

  • oc policy add-role-to-user edit system:serviceaccount:test:<service account name> -n test2
  • oc policy add-role-to-user edit system:serviceaccount:test2:<service account name> -n test

A similar situation also applies for creating or deleting resources via JSON/YAML. A namespace/project which differs from the namespace set for the build step could be specified for any of the resources in the JSON/YAML. If so, similar oc policy invocations to add the edit role for any of those namespaces listed in the JSON/YAML will be needed.

Finally, for any of the build steps, outside of the previously mentioned mounting of the token for the project's default service account into the OpenShift Jenkins image container (assuming OpenShift brings up your Jenkins server), the token can be provided by the user via the following:

  • the field for the token in the specific build step
  • if a string parameter with the key of AUTH_TOKEN is set in the Jenkins Project panel, where the value is the token
  • if a global property with the key of AUTH_TOKEN is set in the Manage Jenkins panel, where the value is the token

Per the OpenShift documentation, see the commands oc describe serviceaccount default and oc describe secret <secret name> for obtaining actual token strings.

Certificates and Encryption

For the certificate, when running in the OpenShift Jenkins image, the CA certificate by default is pulled from the well known location ("/run/secrets/kubernetes.io/serviceaccount/ca.crt") where OpenShift mounts it, and then is stored into the Java KeyStore and X.509 TrustManager for subsequent verification against the OpenShift server on all subsequent interactions. If you wish to override the certificate used:

  • Option 1: set a either a project specific build parameter or global key/value property named CA_CERT_FILE to the file location of the certificate
  • Option 2: For all steps of a given project, set a build parameter (again, of type Text Parameter) named CA_CERT to the string needed to construct the certificate. Since Text Parameter input fields are not available with the global key/value properties, the plug-in does not support defining certificates via a CA_CERT property across Jenkins projects.

If you want to skip TLS verification and allow for untrusted certificates, set the named parameter SKIP_TLS to any value other than false. Since this can be done with a Jenkins String Parameter, you can use this at either the global or project level.

Providing parameter values

For each of the steps and actions provided, with each required parameter, a default value will be inferred whenever possible if the field is left blank (specifics on this are further down in this section). Optional parameters can be left blank as well. And each parameter field has help text available via clicking the help icon located just right of the parameter input field.

Also, when processing any provided values for any of the parameters, the plugin will first see if that value, when used as as key, retrieves a non-null, non-empty value from the Jenkins build environment parameters. If so, the plugin will substitute that value retrieved from the Jenkins build environment parameters in place of what was provided in the input field.

Here are a couple of screen shots to help illustrate. First, the definition of the parameter:

Then how a build step could consume the parameter:

And then how you would run the project, specifying a valid value for the parameter:

An examination of the configuration fields for each type of the build steps will quickly discover that there are some common configuration parameters across the build steps. These common parameters included:

  • the URL of the OpenShift API Endpoint
  • the name of the OpenShift project
  • whether to turn on verbose logging (off by default)
  • the bearer authentication token

For the API Endpoint and Project name, any value specified for the specific step takes precedence. That value can be either the actual value needed to connect, or as articulated above, a Jenkins build environment parameter. But if no value is set, then OpenShift Pipeline plugin will inspect the environment variable available to the OpenShift Jenkins image (where the name of the variable for the endpoint is KUBERNETES_SERVICE_HOST and for the project is PROJECT_NAME). In the case of the API Endpoint, if a non-null, non-empty value is still not obtained after checking the environment variable, the plugin will try to communicate with "https://openshift.default.svc.cluster.local". With the Project name, if neither a specific value is specified or PROJECT_NAME is not set, then the plugin will see if it is running within a Pod where the namespace will be mounted in the file /run/secrets/kubernetes.io/serviceaccount/namespace.

Note that with the "OpenShift ImageStreams" SCM plug-in, these environment variables will not be available when running in the background polling mode (though they are available when that step runs as part of an explicit project build).

Also, when referencing parameters in the build step fields, the following forms can be used:

  • the name as is; for example, for the parameter VERSION, you can use VERSION in the field
  • the name preceded with a $; for the parameter VERSION, you can use $VERSION in the field
  • the name encapsulated with ${..}; for the parameter VERSION, you can use ${VERSION} in the field
  • the name ecapsulated with ${..} and combined with some constant text; for the parameter VERSION, you can specify myapp-${VERSION} in the field

Communication Timeouts

The default timeouts for the various interactions with the OpenShift API endpoint are also configurable for those steps that have to wait on results. Overriding the timeouts are currently done globally across all instances of a given build step or post-build step. Go to the "Configure System" panel under "Manage Jenkins" of the Jenkins UI (i.e. http://host:port/configure), and then change the "Wait interval" for the item of interest. Similarly, the OpenShift Service Verification has a retry count for attempts to contact the OpenShift Service successfully.

Build and Install

Like the Jenkins project itself, this project is a maven based project. To build this project, after you install maven and java 1.8 or later, and cd to this projects root directory (where the pom.xml file is located), run mvn clean package. If built successfully, and openshift-pipeline.hpi file will reside in the target subdirectory.

Aside from building the plugin locally, there are a few other ways to obtain built version of the plugin:

  1. The Centos and RHEL versions of the OpenShift Jenkins Docker Image, starting officially with V3.2 of OpenShift, will have the plugin installed. See the Jenkins Docker Image repository for details.

  2. As noted earlier, wiki page has a link to the latest official version of the plugin.

  3. You could also go to the openshift-pipeline page at the Jenkins Update Center to view the complete list of released plugins.

  4. The Jenkins server used for OpenShift development has a job that build the latest commit to the master repo. The resulting openshift-pipeline.hpi file be a saved artifact from that job.

  5. A RHEL RPM is also available as of V3.2 of OpenShift.

Unless you are using a OpenShift Jenkins Docker Image with the plugin preinstalled, follow the Jenkins instructions for installing a plugin either by supplying the openshift-pipeline.hpi file, or by pulling it down from the Jenkins Update Center.

jenkins-plugin's People

Contributors

adambkaplan avatar akram avatar bparees avatar christophetd avatar csrwng avatar gabemontero avatar jupierce avatar matthicksj avatar nicr9 avatar openshift-merge-robot avatar rhuss avatar stevekuznetsov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jenkins-plugin's Issues

[jenkins workflow] NPE OpenShiftBuilder.inspectBuildEnvAndOverrideFields(OpenShiftBuilder.java:110)

Using plugin v1.0.3

I've got a simple workflow however one thing I noticed is that in the help it suggested an API server name of https://openshift.default.svc.cluster.local where as I dont have an openshift service but a kubernetes one instead, I'm using OpenShift Origin v1.1.0.1

node ('kubernetes'){

  step([$class: 'com.openshift.jenkins.plugins.pipeline.OpenShiftBuilder', apiURL:'https://kubernetes.default', bldCfg:'node-app', namespace:'default', authToken:'blahblah', verbose:'true', commitID:'', buildName:'', showBuildLogs:'true'])

}

which throws this error when run..

Started by user anonymous
[Workflow] Allocate node : Start
Running on 1e01b838afcd5 in /home/jenkins/workspace/workspace/s2i-build
[Workflow] node {
[Workflow] step
[Workflow] } //node
[Workflow] Allocate node : End
[Workflow] End of Workflow
java.lang.NullPointerException
    at com.openshift.jenkins.plugins.pipeline.OpenShiftBuilder.inspectBuildEnvAndOverrideFields(OpenShiftBuilder.java:110)
    at com.openshift.jenkins.plugins.pipeline.OpenShiftBuilder.coreBuildLogic(OpenShiftBuilder.java:168)
    at com.openshift.jenkins.plugins.pipeline.OpenShiftBuilder.perform(OpenShiftBuilder.java:404)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:68)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:59)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:49)
    at hudson.security.ACL.impersonate(ACL.java:213)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:47)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Finished: FAILURE

OpenShiftDeploymentVerifier build step fails with false positive.

I have a build job with a OpenShiftDeploymentVerifier build step. It is configured to verify if there is one pod running after build set. Even though I have one pod running this steps fails hence, my build job fails.

For this test following image has been used.
docker.io/openshift/jenkins-1-centos7 latest 212bac2225d0 6 days ago 655.4 MB

Below you can find the relevant log extract.

OpenShiftDeploymentVerifier rc current count 1 rc desired count 1 step verification amount 1 current state Running
Auth - allowCertificate with incoming chain of len 2
Auth - allowCertificate returning true

OpenShiftDeploymentVerifier latest version: 19
Auth - allowCertificate with incoming chain of len 2
Auth - allowCertificate returning true

OpenShiftDeploymentVerifier current rc {
"kind" : "ReplicationController",
"apiVersion" : "v1",
"metadata" : {
"name" : "cakephp-example-19",
"namespace" : "xyz",
"selfLink" : "/api/v1/namespaces/xyz/replicationcontrollers/cakephp-example-19",
"uid" : "49a7a46a-af9e-11e5-8b2c-fa163ef5b9d0",
"resourceVersion" : "4043011",
"generation" : 2,
"creationTimestamp" : "2015-12-31T09:10:08Z",
"labels" : {
"openshift.io/deployment-config.name" : "cakephp-example",
"template" : "cakephp-example"
},
"annotations" : {
"kubectl.kubernetes.io/desired-replicas" : "0",
"kubectl.kubernetes.io/update-source-id" : "cakephp-example-1:fb35e105-ae32-11e5-8b2c-fa163ef5b9d0",
"openshift.io/deployer-pod.name" : "cakephp-example-19-deploy",
"openshift.io/deployment-config.latest-version" : "19",
"openshift.io/deployment-config.name" : "cakephp-example",
"openshift.io/deployment.phase" : "Running",
"openshift.io/encoded-deployment-config" : "{"kind":"DeploymentConfig","apiVersion":"v1","metadata":{"name":"cakephp-example","namespace":"xyz","selfLink":"/oapi/v1/namespaces/xyz/deploymentconfigs/cakephp-example","uid":"3833352c-ae32-11e5-8b2c-fa163ef5b9d0","resourceVersion":"4042975","creationTimestamp":"2015-12-29T13:44:01Z","labels":{"template":"cakephp-example"},"annotations":{"description":"Defines how to deploy the application server"}},"spec":{"strategy":{"type":"Rolling","rollingParams":{"updatePeriodSeconds":1,"intervalSeconds":1,"timeoutSeconds":600,"maxUnavailable":"25%","maxSurge":"25%"},"resources":{}},"triggers":[{"type":"ImageChange","imageChangeParams":{"automatic":true,"containerNames":["cakephp-example"],"from":{"kind":"ImageStreamTag","name":"cakephp-example:latest"},"lastTriggeredImage":"172.30.209.107:5000/xyz/cakephp-example@sha256:0a8132be3ff05f61d47bf5751b6dd1cb38054f7b208cfe6442821e3651f71cac"}},{"type":"ConfigChange"}],"replicas":1,"selector":{"name":"cakephp-example"},"template":{"metadata":{"name":"cakephp-example","creationTimestamp":null,"labels":{"name":"cakephp-example"}},"spec":{"containers":[{"name":"cakephp-example","image":"172.30.209.107:5000/xyz/cakephp-example@sha256:0a8132be3ff05f61d47bf5751b6dd1cb38054f7b208cfe6442821e3651f71cac","ports":[{"containerPort":8080,"protocol":"TCP"}],"env":[{"name":"DATABASE_SERVICE_NAME"},{"name":"DATABASE_ENGINE"},{"name":"DATABASE_NAME"},{"name":"DATABASE_USER"},{"name":"DATABASE_PASSWORD"},{"name":"CAKEPHP_SECRET_TOKEN","value":"H3N7w8isnMAK6eNeTG8wSU7Fu3xoD6wbmWVEUZ68WkeVKNsrtU"},{"name":"CAKEPHP_SECURITY_SALT","value":"seE36hj8kjfTtKmAeVs8qvtcv2BBQl2sAPmkDwwY"},{"name":"CAKEPHP_SECURITY_CIPHER_SEED","value":"368014367837282015085010621150"},{"name":"OPCACHE_REVALIDATE_FREQ","value":"2"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","securityContext":{}}}},"status":{"latestVersion":19,"details":{"causes":[{"type":"ImageChange","imageTrigger":{"from":{"kind":"DockerImage","name":"172.30.209.107:5000/xyz/cakephp-example:latest"}}}]}}}\n"
}
},
"spec" : {
"replicas" : 1,
"selector" : {
"deployment" : "cakephp-example-19",
"deploymentconfig" : "cakephp-example",
"name" : "cakephp-example"
},
"template" : {
"metadata" : {
"labels" : {
"deployment" : "cakephp-example-19",
"deploymentconfig" : "cakephp-example",
"name" : "cakephp-example"
},
"annotations" : {
"openshift.io/deployment-config.latest-version" : "19",
"openshift.io/deployment-config.name" : "cakephp-example",
"openshift.io/deployment.name" : "cakephp-example-19"
}
},
"spec" : {
"containers" : [{
"name" : "cakephp-example",
"image" : "172.30.209.107:5000/xyz/cakephp-example@sha256:0a8132be3ff05f61d47bf5751b6dd1cb38054f7b208cfe6442821e3651f71cac",
"ports" : [{
"containerPort" : 8080,
"protocol" : "TCP"
}],
"env" : [
{"name" : "DATABASE_SERVICE_NAME"},
{"name" : "DATABASE_ENGINE"},
{"name" : "DATABASE_NAME"},
{"name" : "DATABASE_USER"},
{"name" : "DATABASE_PASSWORD"},
{
"name" : "CAKEPHP_SECRET_TOKEN",
"value" : "H3N7w8isnMAK6eNeTG8wSU7Fu3xoD6wbmWVEUZ68WkeVKNsrtU"
},
{
"name" : "CAKEPHP_SECURITY_SALT",
"value" : "seE36hj8kjfTtKmAeVs8qvtcv2BBQl2sAPmkDwwY"
},
{
"name" : "CAKEPHP_SECURITY_CIPHER_SEED",
"value" : "368014367837282015085010621150"
},
{
"name" : "OPCACHE_REVALIDATE_FREQ",
"value" : "2"
}
],
"terminationMessagePath" : "/dev/termination-log",
"imagePullPolicy" : "IfNotPresent"
}],
"restartPolicy" : "Always",
"terminationGracePeriodSeconds" : 30,
"dnsPolicy" : "ClusterFirst"
}
}
},
"status" : {
"replicas" : 1,
"observedGeneration" : 2
}
}

OpenShiftDeploymentVerifier rc current count 1 rc desired count 1 step verification amount 1 current state Running
Auth - allowCertificate with incoming chain of len 2
Auth - allowCertificate returning true

OpenShiftDeploymentVerifier latest version: 19
Auth - allowCertificate with incoming chain of len 2
Auth - allowCertificate returning true

OpenShiftDeploymentVerifier current rc {
"kind" : "ReplicationController",
"apiVersion" : "v1",
"metadata" : {
"name" : "cakephp-example-19",
"namespace" : "xyz",
"selfLink" : "/api/v1/namespaces/xyz/replicationcontrollers/cakephp-example-19",
"uid" : "49a7a46a-af9e-11e5-8b2c-fa163ef5b9d0",
"resourceVersion" : "4043020",
"generation" : 3,
"creationTimestamp" : "2015-12-31T09:10:08Z",
"labels" : {
"openshift.io/deployment-config.name" : "cakephp-example",
"template" : "cakephp-example"
},
"annotations" : {
"kubectl.kubernetes.io/desired-replicas" : "0",
"kubectl.kubernetes.io/update-source-id" : "cakephp-example-1:fb35e105-ae32-11e5-8b2c-fa163ef5b9d0",
"openshift.io/deployer-pod.name" : "cakephp-example-19-deploy",
"openshift.io/deployment-config.latest-version" : "19",
"openshift.io/deployment-config.name" : "cakephp-example",
"openshift.io/deployment.phase" : "Failed",
"openshift.io/encoded-deployment-config" : "{"kind":"DeploymentConfig","apiVersion":"v1","metadata":{"name":"cakephp-example","namespace":"xyz","selfLink":"/oapi/v1/namespaces/xyz/deploymentconfigs/cakephp-example","uid":"3833352c-ae32-11e5-8b2c-fa163ef5b9d0","resourceVersion":"4042975","creationTimestamp":"2015-12-29T13:44:01Z","labels":{"template":"cakephp-example"},"annotations":{"description":"Defines how to deploy the application server"}},"spec":{"strategy":{"type":"Rolling","rollingParams":{"updatePeriodSeconds":1,"intervalSeconds":1,"timeoutSeconds":600,"maxUnavailable":"25%","maxSurge":"25%"},"resources":{}},"triggers":[{"type":"ImageChange","imageChangeParams":{"automatic":true,"containerNames":["cakephp-example"],"from":{"kind":"ImageStreamTag","name":"cakephp-example:latest"},"lastTriggeredImage":"172.30.209.107:5000/xyz/cakephp-example@sha256:0a8132be3ff05f61d47bf5751b6dd1cb38054f7b208cfe6442821e3651f71cac"}},{"type":"ConfigChange"}],"replicas":1,"selector":{"name":"cakephp-example"},"template":{"metadata":{"name":"cakephp-example","creationTimestamp":null,"labels":{"name":"cakephp-example"}},"spec":{"containers":[{"name":"cakephp-example","image":"172.30.209.107:5000/xyz/cakephp-example@sha256:0a8132be3ff05f61d47bf5751b6dd1cb38054f7b208cfe6442821e3651f71cac","ports":[{"containerPort":8080,"protocol":"TCP"}],"env":[{"name":"DATABASE_SERVICE_NAME"},{"name":"DATABASE_ENGINE"},{"name":"DATABASE_NAME"},{"name":"DATABASE_USER"},{"name":"DATABASE_PASSWORD"},{"name":"CAKEPHP_SECRET_TOKEN","value":"H3N7w8isnMAK6eNeTG8wSU7Fu3xoD6wbmWVEUZ68WkeVKNsrtU"},{"name":"CAKEPHP_SECURITY_SALT","value":"seE36hj8kjfTtKmAeVs8qvtcv2BBQl2sAPmkDwwY"},{"name":"CAKEPHP_SECURITY_CIPHER_SEED","value":"368014367837282015085010621150"},{"name":"OPCACHE_REVALIDATE_FREQ","value":"2"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst","securityContext":{}}}},"status":{"latestVersion":19,"details":{"causes":[{"type":"ImageChange","imageTrigger":{"from":{"kind":"DockerImage","name":"172.30.209.107:5000/xyz/cakephp-example:latest"}}}]}}}\n"
}
},
"spec" : {
"replicas" : 0,
"selector" : {
"deployment" : "cakephp-example-19",
"deploymentconfig" : "cakephp-example",
"name" : "cakephp-example"
},
"template" : {
"metadata" : {
"labels" : {
"deployment" : "cakephp-example-19",
"deploymentconfig" : "cakephp-example",
"name" : "cakephp-example"
},
"annotations" : {
"openshift.io/deployment-config.latest-version" : "19",
"openshift.io/deployment-config.name" : "cakephp-example",
"openshift.io/deployment.name" : "cakephp-example-19"
}
},
"spec" : {
"containers" : [{
"name" : "cakephp-example",
"image" : "172.30.209.107:5000/xyz/cakephp-example@sha256:0a8132be3ff05f61d47bf5751b6dd1cb38054f7b208cfe6442821e3651f71cac",
"ports" : [{
"containerPort" : 8080,
"protocol" : "TCP"
}],
"env" : [
{"name" : "DATABASE_SERVICE_NAME"},
{"name" : "DATABASE_ENGINE"},
{"name" : "DATABASE_NAME"},
{"name" : "DATABASE_USER"},
{"name" : "DATABASE_PASSWORD"},
{
"name" : "CAKEPHP_SECRET_TOKEN",
"value" : "H3N7w8isnMAK6eNeTG8wSU7Fu3xoD6wbmWVEUZ68WkeVKNsrtU"
},
{
"name" : "CAKEPHP_SECURITY_SALT",
"value" : "seE36hj8kjfTtKmAeVs8qvtcv2BBQl2sAPmkDwwY"
},
{
"name" : "CAKEPHP_SECURITY_CIPHER_SEED",
"value" : "368014367837282015085010621150"
},
{
"name" : "OPCACHE_REVALIDATE_FREQ",
"value" : "2"
}
],
"terminationMessagePath" : "/dev/termination-log",
"imagePullPolicy" : "IfNotPresent"
}],
"restartPolicy" : "Always",
"terminationGracePeriodSeconds" : 30,
"dnsPolicy" : "ClusterFirst"
}
}
},
"status" : {
"replicas" : 0,
"observedGeneration" : 3
}
}

BUILD STEP EXIT: OpenShiftDeploymentVerifier deployment cakephp-example-19 failed
Build step 'Check Deployment Success in OpenShift' marked build as failure

Finished: FAILURE

Add support for "Delete OpenShift Resource(s)"

At the moment there is support for creating resources in the plugin (oc create -f), but there is no support for deleting resources (oc delete -f).
It would be nice to have this command also available.

OpenShiftCreator assumes /oapi/v1 endpoints

OpenShiftCreator.java sets up the target URL endpoint using a /oapi/vi/ path string:

url = new URL(apiURL + "/oapi/v1/namespaces/" + namespace + "/" + path + "s");

However, when parsing a JSON List that contains a "Service" item, this undefined endpoint cannot be resolved (404) using /oapi/v1/namespaces/[namespace]/services (OpenShift).

The endpoint can be resolved using the Kubernetes (/api/v1) API endpoint: /api/v1/namespaces/[namespace]/services

Question..

Should there be a 'services' endpoint exposed in oapi/v1 or should this code use the api/v1 endpoint for "Service" requests?

Create OpenShift Resource throws exception even when SKIP_TLS=1

The operation succeeds, but an exception is thrown during fetchApiJsonFromApiServer

Logs:

Started by user admin
Building in workspace /var/jenkins_home/workspace/creator
build env vars:  {=, BUILD_DISPLAY_NAME=#1, BUILD_ID=1, BUILD_NUMBER=1, BUILD_TAG=jenkins-creator-1, BUILD_URL=http://localhost:49001/job/creator/1/, CA_CERTIFICATES_JAVA_VERSION=20140324, CLASSPATH=, COPY_REFERENCE_FILE_LOG=/var/jenkins_home/copy_reference_file.log, EXECUTOR_NUMBER=1, HOME=/var/jenkins_home, HOSTNAME=ac60e305051e, HUDSON_HOME=/var/jenkins_home, HUDSON_SERVER_COOKIE=e9cef694bbb24663, HUDSON_URL=http://localhost:49001/, JAVA_DEBIAN_VERSION=8u102-b14.1-1~bpo8+1, JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64, JAVA_VERSION=8u102, JENKINS_HOME=/var/jenkins_home, JENKINS_SERVER_COOKIE=e9cef694bbb24663, JENKINS_SLAVE_AGENT_PORT=50000, JENKINS_UC=https://updates.jenkins.io, JENKINS_URL=http://localhost:49001/, JENKINS_VERSION=2.7.4, JOB_BASE_NAME=creator, JOB_NAME=creator, JOB_URL=http://localhost:49001/job/creator/, LANG=C.UTF-8, NODE_LABELS=master, NODE_NAME=master, PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin, PWD=/, SHLVL=0, SKIP_TLS=1, TERM=xterm, TINI_SHA=fa23d1e20732501c3bb8eeeca423c89ac80ed452, TINI_VERSION=0.9.0, WORKSPACE=/var/jenkins_home/workspace/creator}
computer env vars:  {CA_CERTIFICATES_JAVA_VERSION=20140324, COPY_REFERENCE_FILE_LOG=/var/jenkins_home/copy_reference_file.log, HOME=/var/jenkins_home, HOSTNAME=ac60e305051e, JAVA_DEBIAN_VERSION=8u102-b14.1-1~bpo8+1, JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64, JAVA_VERSION=8u102, JENKINS_HOME=/var/jenkins_home, JENKINS_SLAVE_AGENT_PORT=50000, JENKINS_UC=https://updates.jenkins.io, JENKINS_VERSION=2.7.4, LANG=C.UTF-8, PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin, PWD=/, SHLVL=0, TERM=xterm, TINI_SHA=fa23d1e20732501c3bb8eeeca423c89ac80ed452, TINI_VERSION=0.9.0}
Creating new auth instance with SKIP_TLS=true


OpenShift Pipeline Plugin: env vars for this job:  {=, BUILD_DISPLAY_NAME=#1, BUILD_ID=1, BUILD_NUMBER=1, BUILD_TAG=jenkins-creator-1, BUILD_URL=http://localhost:49001/job/creator/1/, CA_CERTIFICATES_JAVA_VERSION=20140324, CLASSPATH=, COPY_REFERENCE_FILE_LOG=/var/jenkins_home/copy_reference_file.log, EXECUTOR_NUMBER=1, HOME=/var/jenkins_home, HOSTNAME=ac60e305051e, HUDSON_HOME=/var/jenkins_home, HUDSON_SERVER_COOKIE=e9cef694bbb24663, HUDSON_URL=http://localhost:49001/, JAVA_DEBIAN_VERSION=8u102-b14.1-1~bpo8+1, JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64, JAVA_VERSION=8u102, JENKINS_HOME=/var/jenkins_home, JENKINS_SERVER_COOKIE=e9cef694bbb24663, JENKINS_SLAVE_AGENT_PORT=50000, JENKINS_UC=https://updates.jenkins.io, JENKINS_URL=http://localhost:49001/, JENKINS_VERSION=2.7.4, JOB_BASE_NAME=creator, JOB_NAME=creator, JOB_URL=http://localhost:49001/job/creator/, LANG=C.UTF-8, NODE_LABELS=master, NODE_NAME=master, PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin, PWD=/, SHLVL=0, SKIP_TLS=1, TERM=xterm, TINI_SHA=fa23d1e20732501c3bb8eeeca423c89ac80ed452, TINI_VERSION=0.9.0, WORKSPACE=/var/jenkins_home/workspace/creator}


Starting "Create OpenShift Resource(s)" with the project "myproject".
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
    at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:241)
    at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:198)
    at okhttp3.internal.connection.RealConnection.buildConnection(RealConnection.java:174)
    at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:114)
    at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:193)
    at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129)
    at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at com.openshift.internal.restclient.okhttp.ResponseCodeInterceptor.intercept(ResponseCodeInterceptor.java:54)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
    at okhttp3.RealCall.execute(RealCall.java:60)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.httpGet(IOpenShiftPlugin.java:686)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftApiObjHandler.fetchApiJsonFromApiServer(IOpenShiftApiObjHandler.java:23)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftApiObjHandler.updateApiTypes(IOpenShiftApiObjHandler.java:66)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftCreator.coreLogic(IOpenShiftCreator.java:68)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.doItCore(IOpenShiftPlugin.java:309)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.doIt(IOpenShiftPlugin.java:322)
    at com.openshift.jenkins.plugins.pipeline.OpenShiftBaseStep.perform(OpenShiftBaseStep.java:91)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
    at sun.security.validator.Validator.validate(Validator.java:260)
    at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491)
    ... 46 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
    ... 52 more
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1509)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
    at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:241)
    at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:198)
    at okhttp3.internal.connection.RealConnection.buildConnection(RealConnection.java:174)
    at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:114)
    at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:193)
    at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129)
    at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at com.openshift.internal.restclient.okhttp.ResponseCodeInterceptor.intercept(ResponseCodeInterceptor.java:54)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
    at okhttp3.RealCall.execute(RealCall.java:60)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.httpGet(IOpenShiftPlugin.java:686)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftApiObjHandler.fetchApiJsonFromApiServer(IOpenShiftApiObjHandler.java:23)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftApiObjHandler.updateApiTypes(IOpenShiftApiObjHandler.java:67)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftCreator.coreLogic(IOpenShiftCreator.java:68)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.doItCore(IOpenShiftPlugin.java:309)
    at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.doIt(IOpenShiftPlugin.java:322)
    at com.openshift.jenkins.plugins.pipeline.OpenShiftBaseStep.perform(OpenShiftBaseStep.java:91)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
    at sun.security.validator.Validator.validate(Validator.java:260)
    at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491)
    ... 46 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
    ... 52 more

OpenShiftCreator calling create on for type imagestreams and resource {
    "apiVersion" : "v1",
    "kind" : "ImageStream",
    "metadata" : {"name" : "c1"},
    "spec" : {"tags" : [{
        "from" : {
            "kind" : "DockerImage",
            "name" : "172.30.5.151:5000/myproject/ruby-hello-world:latest"
        },
        "importPolicy" : {},
        "name" : "latest"
    }]},
    "status" : {"dockerImageRepository" : ""}
}
Auth - allowCertificate with incoming chain of len  2
Auth - in skip tls mode, returning true
  Created a "ImageStream"


Exiting "Create OpenShift Resource(s)" successfully, with 1 resource(s) created.
Finished: SUCCESS

java.lang.NullPointerException during build

I used pre-release version of plugin - #34 (comment)

But build continued to work in Openshift.

Started by user admin
Building in workspace /var/lib/jenkins/workspace/images/testing-11.0-drweb-dss-opensuse

Starting the "Trigger OpenShift Build" step with build config "testing-11.0-drweb-dss-opensuse" from the project "images".
Started build "testing-11.0-drweb-dss-opensuse-11" and waiting for build completion ...
ERROR: Build step failed with exception
java.lang.NullPointerException
at com.openshift.jenkins.plugins.pipeline.OpenShiftBuilder.coreLogic(OpenShiftBuilder.java:276)
at com.openshift.jenkins.plugins.pipeline.IOpenShiftPlugin.doItCore(IOpenShiftPlugin.java:123)
at com.openshift.jenkins.plugins.pipeline.IOpenShiftPlugin.doIt(IOpenShiftPlugin.java:134)
at com.openshift.jenkins.plugins.pipeline.OpenShiftBaseStep.perform(OpenShiftBaseStep.java:85)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Build step 'Trigger OpenShift Build' marked build as failure
Finished: FAILURE

Support username and password credentials

Currently, the Jenkins plugin only supports using a token to authenticate itself to the OpenShift master. This is fine if Jenkins is being run from inside OpenShift, but if you have an external Jenkins instance, you have to deal with figuring out how to populate the auth token with a value that expires (by default) every 24 hours. It would be great if the plugin were extended to support authentication via a username and password from the credential store. Ideally, it would log in to the OpenShift master, execute whichever commands, and then log out to destroy the auth token.

In the meantime, I've worked around this by setting up a pipeline job that runs every 12 hours, gets a username and password from a credential entry, logs in to the OpenShift master via curl, parses out the auth token, and stores it in a plain credential. It requires the pipeline plugin, the credentials binding plugin, and the plain credentials plugin. It's also super janky due to limitations of the pipeline plugin (e.g. no ability to get command output, so you have to redirect into a file). Here's the job, in case anybody needs to do this for now:

def token

node {
  withCredentials([[$class: 'UsernamePasswordBinding', credentialsId: 'USER_PASS_CRED_ID', variable: 'OCCREDS']]) {
    sh '''
      curl -v -XGET \\
        --no-keepalive \\
        -u "${OCCREDS}" \\
        -H "X-Csrf-Token: 1" \\
        'https://OPENSHIFT_MASTER:8443/oauth/authorize?response_type=token&client_id=openshift-challenging-client' \\
        2>&1 | \\
        grep 'Location: ' | \\
        sed -E 's/.*access_token=([^&]+)&.*/\\1/' >token
    '''
    token = readFile 'token'
    token = token.trim()
    sh 'rm token'
  }
}

def cred = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
  org.jenkinsci.plugins.plaincredentials.StringCredentials
).find { it.id == 'AUTH_TOKEN_CRED_ID' ? it : null }

def credstore = jenkins.model.Jenkins.instance.getExtensionList(
  'com.cloudbees.plugins.credentials.SystemCredentialsProvider'
)[0].getStore()

def newcred = new org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl(
  cred.scope,
  cred.id,
  cred.description,
  new hudson.util.Secret(token)
)

credstore.updateCredentials(
  com.cloudbees.plugins.credentials.domains.Domain.global(),
  cred,
  newcred
)

On any jobs that you want to use this credential, you bind the plain string credential containing the token to the AUTH_TOKEN environment variable.

Build stage runs for a long time, marked successful after build fails

ruby-sample-build-4 was kicked off by sample-pipeline-4. The s2i build failed after one second, but the pipeline stage ran for ~5 minutes.

openshift_web_console

Much later the pipeline stage was marked as successful even when the build failed.

openshift_web_console

Here is how I'm running the build from my Jenkinsfile

  final project = 'myproject'
  final bc = 'ruby-sample-build'
  final dc = 'frontend'

  stage 'Build'
  def builder = new com.openshift.jenkins.plugins.pipeline.OpenShiftBuilder("", bc, project, "", "", "", "", "true", "", "")
  step builder

I can see the build was failed in the Jenkins log.

Exiting "Trigger OpenShift Build" unsuccessfully; build "ruby-sample-build-4" has completed with status: [Failed].

@gabemontero Will the DSL changes correctly mark the stage as failed when the build fails? https://trello.com/c/jOEuMkze

/cc @bparees @jwforres

tag needs to refer to Image Stream Pull Spec

i think in the change to allow cross project/namespace tags,

it has broken a normal ":promote" type workflow from the ":latest" tag

this change/commented out piece:

https://github.com/openshift/jenkins-plugin/blob/master/src/main/java/com/openshift/jenkins/plugins/pipeline/OpenShiftImageTagger.java#L201

means that if you set up to tag ":latest" with say, ":promote" - you get

$ oc describe is helloworld-mvn

Tag Spec
latest
promote helloworld-mvn:latest

the ":promote" tag should point to the pull spec

promote helloworld-mvn@a01e0a1230c22236fa6d0d03e56356d4ddbef66653b693cee687b80d78673a0c

otherwise promote always equals latest ... not ideal ?

build success but no tag has been created

I use the build step Tag an image in OpenShift

The build is successful but I don't the tag with oc get istag

Here is the log

Started by user Jenkins Admin
Building in workspace /var/lib/jenkins/jobs/foobar-deployer/workspace
Auth - cert file exists



Auth authToken len 1104
inspectBuildEnvAndOverrideFields class name com.openshift.jenkins.plugins.pipeline.OpenShiftImageTagger
inspectBuildEnvAndOverrideFields found field testTag with current value latest
inspectBuildEnvAndOverrideFields for field testTag got val from build env null
inspectBuildEnvAndOverrideFields found field prodTag with current value prod
inspectBuildEnvAndOverrideFields for field prodTag got val from build env null
inspectBuildEnvAndOverrideFields found field apiURL with current value https://<โ€ฆ>:8443
inspectBuildEnvAndOverrideFields for field apiURL got val from build env null
inspectBuildEnvAndOverrideFields found field namespace with current value alep-int
inspectBuildEnvAndOverrideFields for field namespace got val from build env null
inspectBuildEnvAndOverrideFields found field authToken with current value ZXlKaGJHY2lP<...>
inspectBuildEnvAndOverrideFields for field authToken got val from build env null
inspectBuildEnvAndOverrideFields found field verbose with current value true
inspectBuildEnvAndOverrideFields for field verbose got val from build env null
inspectBuildEnvAndOverrideFields found field bearerToken with current value com.openshift.restclient.authorization.TokenAuthorizationStrategy@350c8b87
inspectBuildEnvAndOverrideFields found field auth with current value com.openshift.jenkins.plugins.pipeline.Auth@7cb78f44


BUILD STEP:  OpenShiftImageTagger in perform on namespace foobar-int


BUILD STEP EXIT:  OpenShiftImageTagger image stream now has tags: latest, prod
Finished: SUCCESS

Build trigger fails waiting for logs

this is the jenkins console output. @bparees to provide color.

OpenShift Build myproject/sample-pipeline-1
[Pipeline] node
Still waiting to schedule task
584400d9638 is offline
Running on 6a00e94b7c7 in /tmp/workspace/sample-pipeline
[Pipeline] {
[Pipeline] stage (build)
Entering stage build
Proceeding
[Pipeline] openshiftBuild


Starting the "Trigger OpenShift Build" step with build config "ruby-sample-build" from the project "myproject".
  Started build "ruby-sample-build-1" and waiting for build completion ...


Exiting "Trigger OpenShift Build" unsuccessfully; build "ruby-sample-build-1" has completed with status:  [null].
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: "Trigger OpenShift Build" failed
Finished: FAILURE

NullPointerException at com.openshift.jenkins.plugins.pipeline.OpenShiftCreator.makeRESTCall(OpenShiftCreator.java:96)

`
Started by user admin
Building in workspace /var/lib/jenkins/jobs/2/workspace

Auth authToken len 13
inspectBuildEnvAndOverrideFields class name com.openshift.jenkins.plugins.pipeline.OpenShiftCreator
inspectBuildEnvAndOverrideFields found field jsonyaml with current value {
"apiVersion": "extensions/v1beta1",
"kind": "Job",
"metadata": {
"name": "pi"
},
"spec": {
"selector": {
"matchLabels": {
"app": "pi"
}
},
"parallelism": 1,
"completions": 1,
"template": {
"metadata": {
"name": "pi",
"labels": {
"app": "pi"
}
},
"spec": {
"containers": [
{
"name": "pi",
"image": "perl",
"command": [
"perl",
"-Mbignum=bpi",
"-wle",
"print bpi(2000)"
]
}
],
"restartPolicy": "Never"
}
}
}
}
inspectBuildEnvAndOverrideFields for field jsonyaml got val from build env null
inspectBuildEnvAndOverrideFields found field apiURL with current value https://openshift-master1.livelace.ru
inspectBuildEnvAndOverrideFields for field apiURL got val from build env null
inspectBuildEnvAndOverrideFields found field namespace with current value test
inspectBuildEnvAndOverrideFields for field namespace got val from build env null
inspectBuildEnvAndOverrideFields found field authToken with current value 1111111111111
inspectBuildEnvAndOverrideFields for field authToken got val from build env null
inspectBuildEnvAndOverrideFields found field verbose with current value true
inspectBuildEnvAndOverrideFields for field verbose got val from build env null
inspectBuildEnvAndOverrideFields found field bearerToken with current value com.openshift.restclient.authorization.TokenAuthorizationStrategy@1f
inspectBuildEnvAndOverrideFields found field auth with current value com.openshift.jenkins.plugins.pipeline.Auth@1c9d92bb

BUILD STEP: OpenShiftCreator in perform on namespace test
ERROR: Build step failed with exception
java.lang.NullPointerException
at com.openshift.jenkins.plugins.pipeline.OpenShiftCreator.makeRESTCall(OpenShiftCreator.java:96)
at com.openshift.jenkins.plugins.pipeline.OpenShiftCreator.coreLogic(OpenShiftCreator.java:150)
at com.openshift.jenkins.plugins.pipeline.OpenShiftBaseStep.perform(OpenShiftBaseStep.java:147)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Build step 'Create resource(s) in OpenShift' marked build as failure
Finished: FAILURE
`

FR: Tag images in multiple projects simultaneously

Hello. The quantity of projects are growing and dedicated tag step for each project - it's not convenient. 6 projects and 20 different builds = 120 tag steps (all imagestream in all projects, except central image project).

Can't delete objects by labels

I tried to delete this deployment configuration:

apiVersion: "v1"
kind: "DeploymentConfig"
metadata:
name: "test"
spec:
template:
metadata:
labels:
name: "test"

With Jenkins step:

The type(s) of OpenShift resource(s) to delete: DeploymentConfig
The key(s) of labels on the OpenShift resource(s) to delete: name
The value(s) of labels on the OpenShift resource(s) to delete: test

Logs:

Exiting "Delete OpenShift Resource(s) using Labels" successfully, with 0 resource(s) deleted.
Finished: SUCCESS

Set variables after completed OpenShift Jenkins Build Step

Would be useful if the OpenShift Jenkins plugin could set environment variables after a completed jenkins "Build Step".

For instance after triggering a new build it would be useful if the build instance number/name in OSE or the hash of the resulting image in OpenShift would be available as environment variables in Jenkins.

Similar other "Build Steps" such as "Verify Deployment" could extract information about the resource queried and add these to the environment.

FR: Delete objects with confirmation

Case:

  1. We create objects and they are working.
  2. We send command to delete all objects. Not all objects (Pods) can be deleted immediately and some still are working and they are writing data(until their death). But we already reported about deletion and a next Jenkins task begins started, which want that data will not be changed. It's the problem.

Does not detect build failure ?

 ---> 6073f754f5be
Removing intermediate container 08ba9ce0ddef
Successfully built 6073f754f5be
I0719 05:35:47.252709       1 docker.go:118] Pushing image 172.30.208.158:5000/images/ready-drweb-fss-samba-3.4.0-rpm:11.0 ...

F0719 05:39:36.462583       1 builder.go:204] Error: build error: Failed to push image: Received unexpected HTTP status: 500 Internal Server Error

Jenkins task stays running. 1.0.21-SNAPSHOT (private-a1131ed0-ec2-user)

UP. Task ended with error according to global build timeout:

Exiting "Trigger OpenShift Build" unsuccessfully; build "ready-11.0-drweb-fss-samba-3.4.0-rpm-8" did not complete successfully within the configured timeout of "7200000" ms; last reported status:  [NotStarted].
ERROR: "Trigger OpenShift Build" failed

FR: Using variables as substring in names of configurations

Hello. At the moment we can use variables like this:

VERSION=centos

The name of the DeploymentConfig to scale: VERSION

But we can not do like this:

The name of the DeploymentConfig to scale: drweb-fss-VERSION or drweb-fss-$VERSION or drweb-fss-${VERSION} or drweb-fss-${VERSION}-rpm

We have a lot of similar tasks, which are different only in software version.

FR: The dedicated timeout for deployment verification

@gabemontero

At first, big thanks ๐Ÿ‘ "Verify Deployment Configuration" detects the "postStart" failure situation (regardless of the replica counter)! I checked twice!

For now, we need the simple timeout parameter for the verification of deployment. It allows us to control each deployment (deployment in whole + postStart hook) configuration inside complex configuration.

Pipeline DSL documentation

The documentation for the new Jenkins 2.x documentation is all over the place.

There is this blog post, which is now wrong and outdated: https://blog.openshift.com/pipelines-with-jenkins-2-on-openshift/

This lists bldCfg as the parameter for openshiftBuild but your README references buildConfig
https://jenkins.io/doc/pipeline/steps/openshift-pipeline/

Which one is correct?

In the RedHat OpenShift Workshop it says the best practice is to build the image then run your tests inside the image to control for environment changes, and the workshop shows that process with the OpenShift plugin running in Jenkins 1.x not using pipelines but I see no way to do that with the new 2.x pipeline DSL

Is there any good examples or documentation to how to best apply the OpenShift specific DSL?

Improve the "oc new-app" build task

Add the possibility to create new resources based on a preinstalled template or image just as you can do with

oc new-app https://github.com/openshift/cakephp-ex.git --template=cakephp-example --name=mycake

BuildConfig field for 'Perform builds in OpenShift' build step in Jenkins configure Job form is populated with default value of 'frontend' instead of actual stored value.

Description of problem:

Jenkins job configuration page doesn't present the actual value stored for buildConfig field of a 'Perform builds in OpenShift' build step.

Version-Release number of selected component (if applicable):
OSE v3.1

docker.io/openshift/jenkins-1-centos7 latest 212bac2225d0 6 days ago 655.4 MB

How reproducible:

  • Create a Jenkins Build Job with 'Perform builds in OpenShift'
  • Set BuildConfig value other than 'frontend' and save the build job
  • Click on Configure job link.

Actual results:

BuilConfig filed will be populated with 'frontend' value

Expected results:

BuildConfig form field populated with the actual value

Additional info:

Builds using a build config with a different name than 'frontend' is working hence, it is just a form population issue.

NullPointerException in com.openshift.jenkins.plugins.pipeline.Auth.allowCertificate(Auth.java:86)

Started by user ha:AAAAlx+LCAAAAAAAAP9b85aBtbiIQTGjNKU4P08vOT+vOD8nVc83PyU1x6OyILUoJzMv2y+/JJUBAhiZGBgqihhk0NSjKDWzXb3RdlLBUSYGJk8GtpzUvPSSDB8G5tKinBIGIZ+sxLJE/ZzEvHT94JKizLx0a6BxUmjGOUNodHsLgAzeEgZu/dLi1CL9xJTczDwACG0V4sAAAAA=Jenkins Admin
Building in workspace /var/lib/jenkins/jobs/OpenShift Sample/workspace

BUILD STEP: OpenShiftScaler in perform for frontend wanting to get to replica count 0 on namespace test
ERROR: Build step failed with exception
ha:AAAAWB+LCAAAAAAAAP9b85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=com.openshift.restclient.OpenShiftException: Could not get resource frontend in namespace test: javax.net.ssl.SSLException: java.lang.NullPointerException
at com.openshift.internal.restclient.DefaultClient.createOpenShiftException(DefaultClient.java:480)
at com.openshift.internal.restclient.DefaultClient.get(DefaultClient.java:303)
at com.openshift.jenkins.plugins.pipeline.OpenShiftScaler.coreLogic(OpenShiftScaler.java:74)
at com.openshift.jenkins.plugins.pipeline.OpenShiftBaseStep.perform(OpenShiftBaseStep.java:143)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:408)
Caused by: com.openshift.internal.restclient.http.HttpClientException: javax.net.ssl.SSLException: java.lang.NullPointerException
at com.openshift.internal.restclient.http.UrlConnectionHttpClient.createException(UrlConnectionHttpClient.java:230)
at com.openshift.internal.restclient.http.UrlConnectionHttpClient.request(UrlConnectionHttpClient.java:161)
at com.openshift.internal.restclient.http.UrlConnectionHttpClient.request(UrlConnectionHttpClient.java:140)
at com.openshift.internal.restclient.http.UrlConnectionHttpClient.get(UrlConnectionHttpClient.java:102)
at com.openshift.internal.restclient.DefaultClient.getVersion(DefaultClient.java:371)
at com.openshift.internal.restclient.DefaultClient.getOpenShiftVersions(DefaultClient.java:345)
at com.openshift.internal.restclient.DefaultClient.getOpenShiftAPIVersion(DefaultClient.java:361)
at com.openshift.internal.restclient.DefaultClient.getTypeMappings(DefaultClient.java:405)
at com.openshift.internal.restclient.DefaultClient.getTypeMappings(DefaultClient.java:400)
at com.openshift.internal.restclient.DefaultClient.get(DefaultClient.java:294)
... 11 more
Caused by: javax.net.ssl.SSLException: java.lang.NullPointerException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1890)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1885)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1884)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1457)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
at com.openshift.internal.restclient.http.UrlConnectionHttpClient.createException(UrlConnectionHttpClient.java:213)
... 20 more
Caused by: javax.net.ssl.SSLException: java.lang.NullPointerException
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1906)
at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1889)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1410)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.openshift.internal.restclient.http.UrlConnectionHttpClient.request(UrlConnectionHttpClient.java:157)
... 19 more
Caused by: java.lang.NullPointerException
at com.openshift.jenkins.plugins.pipeline.Auth.allowCertificate(Auth.java:86)
at com.openshift.internal.restclient.http.UrlConnectionHttpClient$CallbackTrustManager.checkServerTrusted(UrlConnectionHttpClient.java:449)
at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(SSLContextImpl.java:922)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
... 26 more
Build step 'Scale deployments in OpenShift' marked build as failure
Finished: FAILURE

Following build logs creates 1 socket/second & duplicate log data

If you create a start-build step & specify that build logs should be streamed, you will see in the Jenkins console that each build log message is appended to the console log multiple times.

In IOpenShiftBuilder.java, you can see why:

        while (System.currentTimeMillis() < (startTime + wait)) {
            bld = client.get(ResourceKind.BUILD, bldId, getNamespace(overrides));
            bldState = bld.getStatus();
            if (Boolean.parseBoolean(getVerbose(overrides)))
                listener.getLogger().println("\nOpenShiftBuilder bld state:  " + bldState);

            if (follow) {
                final String container = pod.getContainers().iterator().next().getName();
                listener.getLogger().println("CONATINERNAME: " + container);

                stop = pod.accept(new CapabilityVisitor<IPodLogRetrievalAsync, IStoppable>() {

Each second, a new pod.accept is being invoked (which creates a net new socket/listener for the life of the build process).

The simple fix is to move the if (follow){...} block outside of the loop. However, invoking .accept too early results in an exception which is currently swallowed by the restclient.

Oct 05, 2016 6:12:57 PM hudson.init.impl.InstallUncaughtExceptionHandler$DefaultUncaughtExceptionHandler uncaughtException
SEVERE: A thread (OkHttp Dispatcher/95) died unexpectedly due to an uncaught exception, this may leave your Jenkins in a bad way and is usually indicative of a bug in the code.
com.openshift.restclient.BadRequestException: https://10.13.137.145:8443/api/v1/namespaces/myproject/pods/ruby-hello-world-8-build/log?container=docker-build&follow=true container "docker-build" in pod "ruby-hello-world-8-build" is waiting to start: ContainerCreating
    at com.openshift.internal.restclient.okhttp.ResponseCodeInterceptor.createOpenShiftException(ResponseCodeInterceptor.java:97)
    at com.openshift.internal.restclient.okhttp.ResponseCodeInterceptor.intercept(ResponseCodeInterceptor.java:59)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
    at okhttp3.RealCall.access$100(RealCall.java:33)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:120)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

In other words, there is presently no (straightforward) way to know whether the operation fails & needs to be retried.

Fixing it might require a slight API break in the openshift-restclient, so I've opened a PR to debate the discuss the change: openshift/openshift-restclient-java#224

default the namespace for the openshift plugin operations when we're executing in a pipeline that has a namespace associated

Some background from @bparees

just because your pipeline buildconfig is defined in one project, doesn't mean that the builds that pipeline triggers are going to reside in the same project.  So while it might be a nicer default to assume it is, the reality is there will still be cases where people are going cross-namespace.

what you really have is 3 namespaces:

1) namespace where jenkins is running
2) namespace where the pipeline buildconfig is defined
3) namespace(s) where the "real" build(s) are defined

any of which could be the same or different.

Today we behave/default to assume that 1+3 are the same.  You're asking us to assume 2+3 are the same.  Which i agree is a slight improvement for some cases, again assuming it's even technically possible for us to hand that information between the sync plugin and the openshift plugin. Gabe would know more about that.

and from @jimmidyson

The sync plugin already attaches info about the OS build to the
Jenkins build cause so you could get the info from there quite easily.

There is also an internal write up from @siamaksade on his attempts to set up pipeline project with an external jenkins.

FR: Post-build Actions - Scale Development

Hello.

Current workflow:

  1. "job-run" - scale development to 1, do something, call "job-down" in any situation (exit 0/1).
  2. "job-down" - scale development to 0, do something.

Why we can't do this in one job, steps:

  1. Scale development to 1
  2. Execute a shell script, which return status of execution on step 1
  3. Scale development to 0

If error will appear on step 2 (exit 1), the step 3 will not be executed and all deployments will stay in working state.

Therefore we should write and maintain two jobs (up/down) instead of one. From this arise problems for batch execution of many of jobs ("job-run" tasks stayed alive until will not be executed "job-down" tasks).

We need post-build action - "scale development".

FR: Support for cross-project tag

Subject. At this moment we can create new tag inside one project but can't do this between projects. Use case: dedicated projects for building images.

FR: Dedicated timeout settings for tasks

SUBJ. At this moment we have global settings for tasks, but it is very inconvenient.

Use case: We have build1, we should set high time out for that build. We have build2, which failed, but we should wait global time out, which we set for build1.

Doesn't detect build error before expiry timeout

What happen:

  1. Set global timeout - 3 hours.
  2. Launch build.
  3. The build ended with error.
  4. Jenkins is waiting 3 hours, to detect error.

Can we detect errors at once, don't wait timeout expiration ?

Add option to ignore SSL errors

I tried using these plugins for Dev -> Test -> Prod process flow. They fail if the OSE cluster has self signed certs. It would be fixed eg. by having checkbox to pass "--insecure-skip-tls-verify" option to oc command in each plugin.

"As a user, I would like to have option to ignore SSL errors in each plugin."

ERROR: Build step failed with exception
com.openshift.restclient.OpenShiftException: javax.net.ssl.SSLHandshakeException while trying to get an authorization context for server https://xxx.ose-demo.xxxxdemo.com:8443

The build error at the beginning

Starting "Create OpenShift Resource(s)" with the project "drweb-netcheck".
ERROR: Build step failed with exception
java.lang.NullPointerException: trustManager == null
at okhttp3.OkHttpClient$Builder.sslSocketFactory(OkHttpClient.java:639)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.httpGet(IOpenShiftPlugin.java:676)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftApiObjHandler.fetchApiJsonFromApiServer(IOpenShiftApiObjHandler.java:23)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftApiObjHandler.updateApiTypes(IOpenShiftApiObjHandler.java:66)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftCreator.coreLogic(IOpenShiftCreator.java:69)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.doItCore(IOpenShiftPlugin.java:310)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.doIt(IOpenShiftPlugin.java:323)
at com.openshift.jenkins.plugins.pipeline.OpenShiftBaseStep.perform(OpenShiftBaseStep.java:91)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Build step 'Create OpenShift Resource(s)' marked build as failure

1.0.22-SNAPSHOT (private-8a31bd9b-ec2-user)

Replace use of System.currentTimeMillis()

currentTimeMillis() is impacted by system clock changes (e.g. daylight savings changes). This can cause wait time calculations relying on the API to behave incorrectly.
These loops can be changed to use System.nanoTime() (with changes to accommodate nanoseconds instead of milliseconds values).

Builds are end with timeout error

See http://openshift-master1.i.drweb.ru:8080/job/images/job/base/76/


Started by upstream project "images/base-meta" build number 25
originally caused by:
Started by user admin
Running as admin
[EnvInject] - Loading node environment variables.
Building remotely on openshift-node2 in workspace http://openshift-master1.i.drweb.ru:8080/job/images/job/base/ws/

Starting the "Trigger OpenShift Build" step with build config "ubuntu-base" from the project "images".
Started build "ubuntu-base-36" and waiting for build completion followed by a new deployment ...
ERROR: Build step failed with exception
com.openshift.internal.restclient.http.HttpClientException: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Timeout: timed out waiting for build ubuntu-base-36 to start after 10s","reason":"Timeout","details":{"retryAfterSeconds":1},"code":504}

at com.openshift.internal.restclient.http.UrlConnectionHttpClient.createException(UrlConnectionHttpClient.java:278)
at com.openshift.internal.restclient.http.UrlConnectionHttpClient.request(UrlConnectionHttpClient.java:211)
at com.openshift.internal.restclient.http.UrlConnectionHttpClient.request(UrlConnectionHttpClient.java:187)
at com.openshift.internal.restclient.http.UrlConnectionHttpClient.get(UrlConnectionHttpClient.java:149)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftBuilder.dumpLogs(IOpenShiftBuilder.java:173)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftBuilder.waitOnBuild(IOpenShiftBuilder.java:121)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftBuilder.coreLogic(IOpenShiftBuilder.java:270)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.doItCore(IOpenShiftPlugin.java:241)
at com.openshift.jenkins.plugins.pipeline.model.IOpenShiftPlugin.doIt(IOpenShiftPlugin.java:254)
at com.openshift.jenkins.plugins.pipeline.OpenShiftBaseStep.perform(OpenShiftBaseStep.java:91)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)

Caused by: java.io.IOException: Server returned HTTP response code: 504 for URL: https://openshift-master1.i.drweb.ru:8443/oapi/v1/namespaces/images/builds/ubuntu-base-36/log
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.openshift.internal.restclient.http.UrlConnectionHttpClient.request(UrlConnectionHttpClient.java:207)
... 17 more
Build step 'Trigger OpenShift Build' marked build as failure

Make methods easier to call from Jenkinsfile pipeline build

Most steps in a Jenkinsfile take named parameters and use a syntax that is very readable. See the following examples:

https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md#understanding-syntax

Is it possible to make it that easy to call OpenShift plugin methods? Today the calls are verbose.

node('agent') {
stage 'build'
def builder = new com.openshift.jenkins.plugins.pipeline.OpenShiftBuilder("", "ruby-sample-build", "myproject", "", "", "", "", "true", "", "")
step builder
stage 'deploy'
def deployer = new com.openshift.jenkins.plugins.pipeline.OpenShiftDeployer("","frontend","myproject","","")
step deployer
}

I want to write something like this

openShiftBuilder buildConfig: 'ruby-sample-build', namespace: 'myproject'

with appropriate defaults for params I leave out. Since end users will need to write Jenkinsfiles, we should make it as easy as possible.

@bparees @gabemontero @sspeiche @jwforres

Crazy duplication in Jenkins console output

Lots of duplication of lines in pages like https://jenkins-demo.router.default.svc.cluster.local/job/sample-pipeline/1/consoleFull , e.g.:

OpenShift Build demo/sample-pipeline-1
[Pipeline] node
Still waiting to schedule task
Waiting for next available executor
Running on maven-e07c2fe6d9 in /tmp/workspace/sample-pipeline
[Pipeline] {
[Pipeline] stage (build)
Entering stage build
Proceeding
[Pipeline] openshiftBuild


Starting the "Trigger OpenShift Build" step with build config "ruby-sample-build" from the project "demo".
  Started build "ruby-sample-build-1" and waiting for build completion ...
Cloning "https://github.com/openshift/ruby-hello-world.git" ...
Cloning "https://github.com/openshift/ruby-hello-world.git" ...
Cloning "https://github.com/openshift/ruby-hello-world.git" ...
Cloning "https://github.com/openshift/ruby-hello-world.git" ...
Cloning "https://github.com/openshift/ruby-hello-world.git" ...
Cloning "https://github.com/openshift/ruby-hello-world.git" ...
Cloning "https://github.com/openshift/ruby-hello-world.git" ...
Cloning "https://github.com/openshift/ruby-hello-world.git" ...
Cloning "https://github.com/openshift/ruby-hello-world.git" ...
Cloning "https://github.com/openshift/ruby-hello-world.git" ...
    Commit: e79d8870be808a7abb4ab304e94c8bee69d909c6 (Merge pull request #53 from danmcp/master)
    Commit: e79d8870be808a7abb4ab304e94c8bee69d909c6 (Merge pull request #53 from danmcp/master)
    Author: Ben Parees <[email protected]>
    Date:   Tue Apr 5 10:06:50 2016 -0400
    Commit: e79d8870be808a7abb4ab304e94c8bee69d909c6 (Merge pull request #53 from danmcp/master)
    Author: Ben Parees <[email protected]>
    Date:   Tue Apr 5 10:06:50 2016 -0400
    Author: Ben Parees <[email protected]>
    Commit: e79d8870be808a7abb4ab304e94c8bee69d909c6 (Merge pull request #53 from danmcp/master)
    Date:   Tue Apr 5 10:06:50 2016 -0400
    Author: Ben Parees <[email protected]>
    Date:   Tue Apr 5 10:06:50 2016 -0400
    Commit: e79d8870be808a7abb4ab304e94c8bee69d909c6 (Merge pull request #53 from danmcp/master)
    Author: Ben Parees <[email protected]>
    Date:   Tue Apr 5 10:06:50 2016 -0400
    Commit: e79d8870be808a7abb4ab304e94c8bee69d909c6 (Merge pull request #53 from danmcp/master)
    Commit: e79d8870be808a7abb4ab304e94c8bee69d909c6 (Merge pull request #53 from danmcp/master)
    Commit: e79d8870be808a7abb4ab304e94c8bee69d909c6 (Merge pull request #53 from danmcp/master)
    Commit: e79d8870be808a7abb4ab304e94c8bee69d909c6 (Merge pull request #53 from danmcp/master)
    Author: Ben Parees <[email protected]>
    Author: Ben Parees <[email protected]>
    Date:   Tue Apr 5 10:06:50 2016 -0400
    Date:   Tue Apr 5 10:06:50 2016 -0400
    Author: Ben Parees <[email protected]>
    Author: Ben Parees <[email protected]>
    Date:   Tue Apr 5 10:06:50 2016 -0400
    Date:   Tue Apr 5 10:06:50 2016 -0400
    Commit: e79d8870be808a7abb4ab304e94c8bee69d909c6 (Merge pull request #53 from danmcp/master)
    Author: Ben Parees <[email protected]>
    Date:   Tue Apr 5 10:06:50 2016 -0400
---> Installing application source ...
---> Building your Ruby application from source ...
---> Installing application source ...
---> Building your Ruby application from source ...
---> Installing application source ...
---> Building your Ruby application from source ...
---> Installing application source ...
---> Installing application source ...
---> Installing application source ...
---> Building your Ruby application from source ...
---> Building your Ruby application from source ...
---> Installing application source ...
---> Installing application source ...
---> Running 'bundle install --deployment' ...
---> Building your Ruby application from source ...
---> Running 'bundle install --deployment' ...
---> Running 'bundle install --deployment' ...
---> Building your Ruby application from source ...
---> Installing application source ...
---> Building your Ruby application from source ...
---> Running 'bundle install --deployment' ...
---> Building your Ruby application from source ...
---> Running 'bundle install --deployment' ...
---> Running 'bundle install --deployment' ...
---> Installing application source ...
---> Building your Ruby application from source ...
---> Running 'bundle install --deployment' ...
---> Running 'bundle install --deployment' ...
---> Running 'bundle install --deployment' ...
---> Running 'bundle install --deployment' ...

Trigger OpenShift Build Options

Can I use options --from-file in Trigger Openshift Build. I using external Jenkins for build and Openshift Origin just for binary deployment. I want to start Openshift build from Jenkins Plugin with options --from-file.

How could I do?

Thanks.

Concurrent builds with differing parameters from environment variables are not possible

When a build is started with an OpenShift build step, it reads the parameters assigned in the job configuration. Then, it checks to see if any of the values correspond to environment variables. If they do, it uses the values of the environment variables instead of the value in the job config. This is all fine. The problem is that the way it does this is to actually change the values in the job configuration itself, run the build step, and then change them back. As a side effect, attempting to run the same build multiple times concurrently (or, sometimes, just multiple times sequentially with minimal delay between them) with differing values for the environment variables will result in the build step using the first parameters twice.

To illustrate the issue, here is a build step:

before a build

And here is that same build step during a build:

during a build

Any additional builds invoked while the first build is in progress will get those values, rather than the ones passed as parameters.

Better messages in Jenkins job logs

BUILD STEP: OpenShiftScaler in perform for frontend wanting to get to replica count 0 on namespace test

Should be something like "Scaling deployment 'frontend' in namespace 'test' to 0 replicas"

BUILD STEP EXIT: OpenShiftScaler got the scale request through

Dunno what this means :-)

BUILD STEP: OpenShiftBuilder in perform for ruby-sample-build on namespace test

Should be "Starting build #number for 'ruby-sample-build' in namespace 'test'". Alternatively, when the deployment check is in place we can add " and waiting for deployment to succeed".

BUILD STEP: OpenShiftDeploymentVerifier in perform checking for frontend wanting to confirm we are at least at replica count 0 on namespace test

Should be "Waiting for the 'frontend' to reach number of replicas to be 0"

...
I think we need to cleanup this :-) I think the EXIT steps are not necessary. We should try to be less verbose and don't use something like "OpenShiftDeploymentVerifier" as users (and me) have no idea what that is :-)

Also can we show links to OpenShift console so users can follow the build (to watch logs/cancel/etc)?

FR: Command execution inside specific pod

Hello. What I need in my QA work:

Workflow:

  1. Build image.
  2. Deploy replication controllers with services (HTTP, FTP, SMTP etc.)
  3. Run specific Pod with my application inside. I want to exec commands inside this Pod, which will be test my application for establishing a connection with services (step 2). And pipe output back to jenkins.

Maybe execution should be attached to Pod labels and execute command on bunch of Pods.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.