Issue
I have this Jenkinsfile
pipeline {
agent any
tools {
maven 'maven381'
jdk 'JDK904'
oc 'oc'
}
parameters {
string(name:'CLUSTER_NAME',defaultValue:'openshift-cluster',description:'Cluster name space')
string(name:'PROJECT_NAME',defaultValue:'etias-sword-dev',description:'Cluster project name')
}
stages {
stage('Build') {
steps {
script {
openshift.withCluster(CLUSTER_NAME) {
openshift.withProject(PROJECT_NAME) {
openshift.newApp('--image-stream="openshift/java:11"~https://github.com/filip123go/Simplest-Spring-Boot-Hello-World.git --env=MAVEN_OPTS=-Dhttps.protocols=TLSv1.2')
}
}
}
}
}
}
}
I want to pass inside the Environment variable
MAVEN_OPTS=-Dhttps.protocols=TLSv1.2
so every time I run the job in Jenkins the Environment variable passes automatically. I know that the cli command in openshift is
oc set env bc simplest-spring-boot-hello-world MAVEN_OPTS=-Dhttps.protocols=TLSv1.2
I have already tried with no success
openshift.newApp('--image-stream="openshift/java:11"~https://github.com/filip123go/Simplest-Spring-Boot-Hello-World.git --env=MAVEN_OPTS=-Dhttps.protocols=TLSv1.2')
and
openshift.newApp('--image-stream="openshift/java:11"~https://github.com/filip123go/Simplest-Spring-Boot-Hello-World.git --param=MAVEN_OPTS=-Dhttps.protocols=TLSv1.2')
and
openshift.newApp('--image-stream="openshift/java:11"~https://github.com/filip123go/Simplest-Spring-Boot-Hello-World.git MAVEN_OPTS=-Dhttps.protocols=TLSv1.2')
and
openshift.newApp('--image-stream="openshift/java:11"~https://github.com/filip123go/Simplest-Spring-Boot-Hello-World.git -e=MAVEN_OPTS=-Dhttps.protocols=TLSv1.2')
with no success. Could you please help?
Solution
After a lot of experimentation (and by reading the documentation) this is the correct way to pass inside the Environment variable
openshift.newApp('--image-stream="openshift/java:11"~https://github.com/filip123go/Simplest-Spring-Boot-Hello-World.git --build-env MAVEN_OPTS=-Dhttps.protocols=TLSv1.2')
this is the updated Jenkins File :
pipeline {
agent any
tools {
maven 'maven381'
jdk 'JDK904'
oc 'oc'
}
parameters {
string(name:'CLUSTER_NAME',defaultValue:'openshift-cluster',description:'Cluster name space')
string(name:'PROJECT_NAME',defaultValue:'etias-sword-dev',description:'Cluster project name')
}
stages {
stage('Build') {
steps {
script {
openshift.withCluster(CLUSTER_NAME) {
openshift.withProject(PROJECT_NAME) {
openshift.newApp('--image-stream="openshift/java:11"~https://github.com/filip123go/Simplest-Spring-Boot-Hello-World.git --build-env MAVEN_OPTS=-Dhttps.protocols=TLSv1.2')
}
}
}
}
}
}
}
Answered By - Filip123go
Answer Checked By - Gilberto Lyons (JavaFixing Admin)