Skip to content

Commit 88ec83f

Browse files
Merge pull request #17203 from juanvallejo/jvallejo/support-env-update-jenkinspipeline
Automatic merge from submit-queue (batch tested with PRs 17202, 17203). add support for JenkinsPipeline strategy env update Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1509793 Adds support for updating environment variables on buildConfigs that use the JenkinsPipeline strategy. /kind bug cc @openshift/cli-review @bparees
2 parents 985a79b + 67c911b commit 88ec83f

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pkg/cmd/util/clientcmd/factory.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ func (f *Factory) UpdateObjectEnvironment(obj runtime.Object, fn func(*[]api.Env
125125
if t.Spec.Strategy.DockerStrategy != nil {
126126
return true, fn(&t.Spec.Strategy.DockerStrategy.Env)
127127
}
128+
if t.Spec.Strategy.JenkinsPipelineStrategy != nil {
129+
return true, fn(&t.Spec.Strategy.JenkinsPipelineStrategy.Env)
130+
}
128131
}
129132
return false, fmt.Errorf("object does not contain any environment variables")
130133
}

test/cmd/env.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,27 @@ os::cmd::expect_success_and_text 'oc set env dc/node --env PASS=x,y=z' 'no longe
2121
# warning is not printed for variables passed as positional arguments
2222
os::cmd::expect_success_and_not_text 'oc set env dc/node PASS=x,y=z' 'no longer accepts comma-separated list'
2323

24+
# create a build-config object with the JenkinsPipeline strategy
25+
os::cmd::expect_success 'oc process -p NAMESPACE=openshift -f examples/jenkins/jenkins-ephemeral-template.json | oc create -f -'
26+
os::cmd::expect_success "echo 'apiVersion: v1
27+
kind: BuildConfig
28+
metadata:
29+
name: fake-pipeline
30+
spec:
31+
source:
32+
git:
33+
uri: git://github.com/openshift/ruby-hello-world.git
34+
strategy:
35+
jenkinsPipelineStrategy: {}
36+
' | oc create -f -"
37+
38+
# ensure build-config has been created and that its type is "JenkinsPipeline"
39+
os::cmd::expect_success_and_text "oc get bc fake-pipeline -o jsonpath='{ .spec.strategy.type }'" 'JenkinsPipeline'
40+
# attempt to set an environment variable
41+
os::cmd::expect_success_and_text 'oc set env bc/fake-pipeline FOO=BAR' 'buildconfig "fake\-pipeline" updated'
42+
# ensure environment variable was set
43+
os::cmd::expect_success_and_text "oc get bc fake-pipeline -o jsonpath='{ .spec.strategy.jenkinsPipelineStrategy.env }'" 'name\:FOO'
44+
os::cmd::expect_success 'oc delete bc fake-pipeline'
45+
2446
echo "oc set env: ok"
2547
os::test::junit::declare_suite_end

0 commit comments

Comments
 (0)