Skip to content

Commit

Permalink
Add windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrille-leclerc committed Feb 22, 2021
1 parent 8edeaf9 commit 8775e43
Showing 1 changed file with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.jenkins.plugins.opentelemetry;

import hudson.ExtensionList;
import hudson.Functions;
import hudson.model.Result;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
Expand Down Expand Up @@ -123,25 +124,28 @@ public void testSimplePipeline() throws Exception {

@Test
public void testTraceEnvironmentVariablesInjectedInShellSteps() throws Exception {
String pipelineScript = "def xsh(cmd) {if (isUnix()) {sh cmd} else {bat cmd}};\n" +
"node() {\n" +
" stage('ze-stage1') {\n" +
" xsh '''\n" +
"if [ -z $TRACEPARENT ]\n" +
"then\n" +
" echo TRACEPARENT NOT FOUND\n" +
" exit 1\n" +
"fi\n" +
"'''\n" +
" }\n" +
"}";
WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "test-trace-environment-variables-injected-in-shell-steps-" + jobNameSuffix.incrementAndGet());
pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true));
WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0));

List<SpanData> finishedSpanItems = flush();
dumpSpans(finishedSpanItems);
MatcherAssert.assertThat(finishedSpanItems.size(), CoreMatchers.is(6));
if (Functions.isWindows()) {
// TODO test on windows
} else {
String pipelineScript = "node() {\n" +
" stage('ze-stage1') {\n" +
" sh '''\n" +
"if [ -z $TRACEPARENT ]\n" +
"then\n" +
" echo TRACEPARENT NOT FOUND\n" +
" exit 1\n" +
"fi\n" +
"'''\n" +
" }\n" +
"}";
WorkflowJob pipeline = jenkinsRule.createProject(WorkflowJob.class, "test-trace-environment-variables-injected-in-shell-steps-" + jobNameSuffix.incrementAndGet());
pipeline.setDefinition(new CpsFlowDefinition(pipelineScript, true));
WorkflowRun build = jenkinsRule.assertBuildStatus(Result.SUCCESS, pipeline.scheduleBuild2(0));

List<SpanData> finishedSpanItems = flush();
dumpSpans(finishedSpanItems);
MatcherAssert.assertThat(finishedSpanItems.size(), CoreMatchers.is(6));
}
}


Expand Down

0 comments on commit 8775e43

Please sign in to comment.