Ejemplo n.º 1
0
        public void InstantiatePipelineTest()
        {
            IPipelineBuilder builder = new PipelineBuilderImpl();

            builder.Pipeline("myPipeline").
            TriggerOn(TriggerType.Push).
            AddGlobals().
            RunsOn(OperatingSystem.UbuntuLatest).
            SetEnvVar("MY_ENV_VAR", "HELLO WORLD!").
            AddStep("Default Checkout step").
            AsAction().
            Execute("actions/checkout@v2").
            AddStep("Default clean step").
            AsShell().
            Execute("echo \"My Global Job\"").
            Execute("mvn clean").
            InDirectory("./TANKS").
            AddJob("compile").
            AddStep("Compile Step").
            AsShell().
            Execute("mvn compile").
            InDirectory("./TANKS").
            AddJob("unittest").
            AddStep("Unit Test Step").
            AsShell().
            Execute("mvn verify").
            InDirectory("./TANKS");

            builder.Build();
            Pipeline p = builder.Collect();
        }
Ejemplo n.º 2
0
        public void GenerateYAML1()
        {
            IPipelineBuilder builder = new PipelineBuilderImpl();

            builder.Pipeline("myPipeline").
            TriggerOn(TriggerType.Push).
            AddGlobals().
            RunsOn(OperatingSystem.UbuntuLatest).
            SetEnvVar("MY_ENV_VAR", "HELLO WORLD!").
            AddStep("Default Checkout step").
            AsAction().
            Execute("actions/checkout@v2").
            AddStep("Default clean step").
            AsShell().
            Execute("echo \"My Global Job\"").
            Execute("mvn clean").
            InDirectory("./TANKS").
            AddJob("compile").
            AddStep("Compile Step").
            AsShell().
            Execute("mvn compile").
            InDirectory("./TANKS").
            AddJob("unittest").
            AddStep("Unit Test Step").
            AsShell().
            Execute("mvn verify").
            InDirectory("./TANKS");

            builder.Build();
            _pipeline = builder.Collect();

            PipelineCodeGen codeGen = new PipelineCodeGen(_pipeline, 2);
            string          YAML    = codeGen.Generate();

            Console.WriteLine(YAML);
        }
Ejemplo n.º 3
0
        public void GenerateYAML2()
        {
            IPipelineBuilder builder = new PipelineBuilderImpl();

            string workDir = "./TANKS";

            builder.Pipeline("myPipeline").
            TriggerOn(TriggerType.Push).
            AddGlobals().
            RunsOn(OperatingSystem.UbuntuLatest).
            SetEnvVar("MY_ENV_VAR", "HELLO WORLD!").
            AddStep("Default Checkout step").
            AsAction().
            Execute("actions/checkout@v2").
            AddStep("Default clean step").
            AsShell().
            Execute("echo \"My Global Job\"").
            Execute("echo \"Value of global env var: \" $MY_ENV_VAR").
            Execute("mvn clean").
            InDirectory(workDir).
            AddJob("compile").
            SetName("Compile").
            AddStep("Compile Step").
            AsShell().
            Execute("mvn compile").
            InDirectory(workDir).
            AddJob("unit-test").
            SetName("Unit test").
            RunsOn(OperatingSystem.Ubuntu1604).
            DependsOn("compile").
            AddStep("Unit Test Step").
            AsShell().
            Execute("mvn verify").
            InDirectory(workDir).
            AddJob("package").
            SetName("Package").
            RunsOn(OperatingSystem.Ubuntu1804).
            DependsOn("unit-test").
            SetEnvVar("MY_ENV_VAR", "HELLO FYN").
            SetEnvVar("LOCAL_VAR", "HELLO ODENSE").
            AddStep("Maven package").
            AsShell().
            Execute("mvn package").
            Execute("echo \"Value of overridden global env var: \" $MY_ENV_VAR").
            Execute("echo \"Value of local env var: \" $LOCAL_VAR").
            InDirectory(workDir).
            AddJob("install").
            SetName("Install").
            DependsOn("package").
            AddStep("Maven install").
            AsShell().
            Execute("mvn install").
            InDirectory(workDir);

            builder.Build();
            _pipeline = builder.Collect();

            PipelineCodeGen codeGen = new PipelineCodeGen(_pipeline, 2);
            string          YAML    = codeGen.Generate();

            Console.WriteLine(YAML);
            Console.WriteLine("##############################################");
            Console.WriteLine();
            codeGen.Indent = 4;
            YAML           = codeGen.Generate();
            Console.WriteLine(YAML);
        }
Ejemplo n.º 4
0
        public void InstantiateTANKSPipelineTest()
        {
            IPipelineBuilder builder = new PipelineBuilderImpl();

            string tanksDir       = "./TANKS";
            string checkoutAction = "actions/checkout@v2";
            string dockerAction   = "docker://cfeicommon/maven-jdk8-fx:latest";

            builder.Pipeline("CI")
            .TriggerOn(TriggerType.Push)

            .AddGlobals().
            RunsOn(OperatingSystem.UbuntuLatest).
            SetEnvVar("MY_ENV_VAR", "HELLO WORLD!").
            AddStep("Default Checkout step").
            AsAction().
            Execute("actions/checkout@v2")

            .AddJob("compile")
            .RunsOn(OperatingSystem.UbuntuLatest)
            .AddStep("Checkout repo")
            .AsAction()
            .Execute(checkoutAction)
            .AddStep("Pull Docker Image")
            .AsAction()
            .Execute(dockerAction)
            .AddStep("Compile Tanks")
            .AsShell()
            .Execute("mvn compile")
            .InDirectory(tanksDir)

            .AddJob("unit-test")
            .RunsOn(OperatingSystem.UbuntuLatest)
            .DependsOn("compile")
            .AddStep("Checkout repo")
            .AsAction()
            .Execute(checkoutAction)
            .AddStep("Pull Docker Image")
            .AsAction()
            .Execute(dockerAction)
            .AddStep("Execute unit test TANKS")
            .AsShell()
            .Execute("Running mvn verify")
            .Execute("mvn verify")
            .InDirectory(tanksDir)

            .AddJob("package")
            .RunsOn(OperatingSystem.UbuntuLatest)
            .DependsOn("unit-test")
            .AddStep("Checkout repo")
            .AsAction()
            .Execute(checkoutAction)
            .AddStep("Pull Docker Image")
            .AsAction()
            .Execute(dockerAction)
            .AddStep("Package TANKS")
            .AsShell()
            .Execute("mvn package")
            .InDirectory(tanksDir)

            .AddJob("install")
            .RunsOn(OperatingSystem.UbuntuLatest)
            .DependsOn("package")
            .AddStep("Checkout repo")
            .AsAction()
            .Execute(checkoutAction)
            .AddStep("Pull Docker Image")
            .AsAction()
            .Execute(dockerAction)
            .AddStep("Install TANKS")
            .AsShell()
            .Execute("mvn install")
            .InDirectory(tanksDir);

            builder.Build();
            Pipeline p = builder.Collect();
        }