Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM-CI] APM UI pipeline version 0 #4

Merged
merged 60 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
377a8b9
APM UI pipeline version 0
kuisathaverat Nov 28, 2018
5888c5f
fis errors
kuisathaverat Nov 28, 2018
adf0248
fis errors
kuisathaverat Nov 28, 2018
1ff8df6
fis errors
kuisathaverat Nov 28, 2018
c167517
define proper stash steps
kuisathaverat Nov 28, 2018
4444eac
typo
kuisathaverat Nov 28, 2018
7699107
move initializing out of the paralel step
kuisathaverat Nov 28, 2018
b43fe94
define proper stash steps
kuisathaverat Nov 28, 2018
44e07da
define proper stash steps
kuisathaverat Nov 28, 2018
d255c55
define proper stash steps
kuisathaverat Nov 28, 2018
0ea3c01
define proper stash steps
kuisathaverat Nov 28, 2018
bdeabd5
define proper stash steps
kuisathaverat Nov 28, 2018
864c635
define proper stash steps
kuisathaverat Nov 28, 2018
de5cdf0
define proper stash steps
kuisathaverat Nov 28, 2018
df177ae
remove library, enable ansicolor
kuisathaverat Nov 29, 2018
b11806d
Merge branch 'master' of github.com:elastic/apm-pipeline-library
kuisathaverat Nov 29, 2018
265420c
nit
kuisathaverat Nov 29, 2018
8c80700
some jenkins file changes
kuisathaverat Nov 30, 2018
71f828c
merge master
kuisathaverat Dec 3, 2018
94ce44c
add 'yarn bin' to the PATH
kuisathaverat Dec 3, 2018
3dc7678
set GIT_URL
kuisathaverat Dec 3, 2018
0de51f4
input step to inspect the container
kuisathaverat Dec 4, 2018
f155b87
input step to inspect the container
kuisathaverat Dec 4, 2018
9d2454b
input step to inspect the container
kuisathaverat Dec 4, 2018
ec80188
input step to inspect the container
kuisathaverat Dec 4, 2018
14822d0
fix stash step
kuisathaverat Dec 4, 2018
247d8e3
fix stash step
kuisathaverat Dec 4, 2018
59e5f84
fix stash step
kuisathaverat Dec 4, 2018
b00a0ae
fix codecov help
kuisathaverat Dec 4, 2018
19c1f52
make bootstrap before test
kuisathaverat Dec 4, 2018
2f22617
remove input step
kuisathaverat Dec 4, 2018
ded5f6e
restore stash
kuisathaverat Dec 4, 2018
cb2c78f
remove skip-node-download option does not work as expected
kuisathaverat Dec 4, 2018
cbef597
Merge branch 'master' of github.com:elastic/apm-pipeline-library into…
kuisathaverat Dec 5, 2018
495d2bb
Merge branch 'master' of github.com:elastic/apm-pipeline-library into…
kuisathaverat Dec 5, 2018
e6925ee
simplify APM UI pipeline launch
kuisathaverat Dec 11, 2018
869c8da
refactor
kuisathaverat Dec 11, 2018
cde1264
use kibana 6.5 branch
kuisathaverat Dec 11, 2018
00cc307
fix test
kuisathaverat Dec 11, 2018
259af2a
new log step
kuisathaverat Dec 11, 2018
8099c87
update README
kuisathaverat Dec 11, 2018
54df8bc
select ES version
kuisathaverat Dec 11, 2018
1aa57de
ad yarn modules to the path
kuisathaverat Dec 11, 2018
b762830
add yarn modules to the path
kuisathaverat Dec 11, 2018
dcf8875
add yarn modules to the path
kuisathaverat Dec 11, 2018
efa32f6
install node is faster
kuisathaverat Dec 11, 2018
cbf11fd
checkout is faster
kuisathaverat Dec 11, 2018
debab08
checkout is faster
kuisathaverat Dec 11, 2018
7463169
Map def error
kuisathaverat Dec 11, 2018
f7116a5
stop container to make a test
kuisathaverat Dec 12, 2018
299faa1
some adjustments
kuisathaverat Dec 12, 2018
50d5060
update template
kuisathaverat Dec 12, 2018
9e56869
some adjustments
kuisathaverat Dec 12, 2018
ba2976a
add cleanAfter, cleanBefore, and baseDir to the withEnvWrapper step
kuisathaverat Dec 12, 2018
d1f754d
add cleanAfter, cleanBefore, and baseDir to the withEnvWrapper step
kuisathaverat Dec 12, 2018
a956b3f
add cleanAfter, cleanBefore, and baseDir to the withEnvWrapper step
kuisathaverat Dec 12, 2018
a58fdbb
add cleanAfter, cleanBefore, and baseDir to the withEnvWrapper step
kuisathaverat Dec 12, 2018
edee541
use cache
kuisathaverat Dec 12, 2018
a300738
update README
kuisathaverat Dec 12, 2018
e735878
refactor
kuisathaverat Dec 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion resources/JenkinsfileTemplate.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pipeline {
parameters {
string(name: 'PARAM_WITH_DEFAULT_VALUE', defaultValue: "defaultValue", description: "it would not be defined on the first build, see JENKINS-41929.")
booleanParam(name: 'Run_As_Master_Branch', defaultValue: false, description: 'Allow to run any steps on a PR, some steps normally only run on master branch.')
booleanParam(name: 'doc_ci', defaultValue: true, description: 'Enable build docs.')
}
stages {
stage('Initializing'){
Expand Down Expand Up @@ -87,7 +88,7 @@ pipeline {
tag "v\\d+\\.\\d+\\.\\d+*"
environment name: 'Run_As_Master_Branch', value: 'true'
}
environment name: 'doc_ci', value: 'true'
expression { return params.doc_ci }
}
}
steps {
Expand Down
19 changes: 19 additions & 0 deletions src/test/groovy/DummyStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ class DummyStepTests extends BasePipelineTest {
helper.registerAllowedMethod("sh", [String.class], { "OK" })
helper.registerAllowedMethod("withEnvWrapper", [Closure.class], { closure -> closure.call() })
helper.registerAllowedMethod("script", [Closure.class], { closure -> closure.call() })
helper.registerAllowedMethod("pipeline", [Closure.class], { body -> body() })
helper.registerAllowedMethod("agent", [String.class], { "OK" })
helper.registerAllowedMethod("agent", [Closure.class], { body -> body() })
helper.registerAllowedMethod("label", [String.class], { "OK" })
helper.registerAllowedMethod("stages", [Closure.class], { body -> body() })
helper.registerAllowedMethod("steps", [Closure.class], { body -> body() })
helper.registerAllowedMethod("post", [Closure.class], { body -> body() })
helper.registerAllowedMethod("success", [Closure.class], { body -> body() })
helper.registerAllowedMethod("aborted", [Closure.class], { body -> body() })
helper.registerAllowedMethod("failure", [Closure.class], { body -> body() })
helper.registerAllowedMethod("unstable", [Closure.class], { body -> body() })
helper.registerAllowedMethod("always", [Closure.class], { body -> body() })
helper.registerAllowedMethod("dir", [String.class, Closure.class], { path, body -> body() })
helper.registerAllowedMethod("when", [Closure.class], { "OK" })
helper.registerAllowedMethod("parallel", [Closure.class], { body -> body() })
helper.registerAllowedMethod("failFast", [Boolean.class], { "OK" })
helper.registerAllowedMethod("script", [Closure.class], { body -> body() })
helper.registerAllowedMethod("options", [Closure.class], { "OK" })
helper.registerAllowedMethod("environment", [Closure.class], { "OK" })
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion src/test/groovy/GitCheckoutStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class GitCheckoutStepTests extends BasePipelineTest {
helper.registerAllowedMethod("sh", [Map.class], { "OK" })
helper.registerAllowedMethod("sh", [String.class], { "OK" })
helper.registerAllowedMethod("checkout", [String.class], { "OK" })
helper.registerAllowedMethod("github_enterprise_constructor", [], { "OK" })
helper.registerAllowedMethod("githubEnv", [], { "OK" })
helper.registerAllowedMethod("withEnvWrapper", [Closure.class], { closure -> closure.call() })
}

Expand Down
116 changes: 116 additions & 0 deletions src/test/groovy/LogStepTests.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import com.lesfurets.jenkins.unit.BasePipelineTest
import org.junit.Before;
import org.junit.Test;
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
import static org.junit.Assert.assertTrue

class LogStepTests extends BasePipelineTest {
Map env = [:]

@Override
@Before
void setUp() throws Exception {
super.setUp()

env.WORKSPACE = "WS"
binding.setVariable('env', env)
helper.registerAllowedMethod("echoColor", [Map.class], { m ->
def echoColor = loadScript("vars/echoColor.groovy")
echoColor.call(m)
})
}

@Test
void test() throws Exception {
def script = loadScript("vars/log.groovy")
env.PIPELINE_LOG_LEVEL = 'DEBUG'
script.call(text: "message")
printCallStack()
assertTrue(helper.callStack.findAll { call ->
call.methodName == "echo"
}.any { call ->
callArgsToString(call).contains("message")
callArgsToString(call).contains("[DEBUG]")
})
assertJobStatusSuccess()
}

@Test
void testDebug() throws Exception {
def script = loadScript("vars/log.groovy")
env.PIPELINE_LOG_LEVEL = 'DEBUG'
script.call(level: 'DEBUG', text: "message")
printCallStack()
assertTrue(helper.callStack.findAll { call ->
call.methodName == "echo"
}.any { call ->
callArgsToString(call).contains("message")
callArgsToString(call).contains("[DEBUG]")
})
assertJobStatusSuccess()
}

@Test
void testInfo() throws Exception {
def script = loadScript("vars/log.groovy")
script.call(level: 'INFO', text: "message")
printCallStack()
assertTrue(helper.callStack.findAll { call ->
call.methodName == "echo"
}.any { call ->
callArgsToString(call).contains("message")
callArgsToString(call).contains("[INFO]")
})
assertJobStatusSuccess()
}

@Test
void testWarn() throws Exception {
def script = loadScript("vars/log.groovy")
env.PIPELINE_LOG_LEVEL = 'WARN'
script.call(level: 'WARN', text: "message")
printCallStack()
assertTrue(helper.callStack.findAll { call ->
call.methodName == "echo"
}.any { call ->
callArgsToString(call).contains("message")
callArgsToString(call).contains("[WARN]")
})
assertJobStatusSuccess()
}

@Test
void testError() throws Exception {
def script = loadScript("vars/log.groovy")
env.PIPELINE_LOG_LEVEL = 'ERROR'
script.call(level: 'ERROR', text: "message")
printCallStack()
assertTrue(helper.callStack.findAll { call ->
call.methodName == "echo"
}.any { call ->
callArgsToString(call).contains("message")
callArgsToString(call).contains("[ERROR]")
})
assertJobStatusSuccess()
}

@Test
void testLevel() throws Exception {
def script = loadScript("vars/log.groovy")
env.PIPELINE_LOG_LEVEL = 'WARN'
script.call(level: 'DEBUG', text: "messageDEBUG")
script.call(level: 'INFO', text: "messageINFO")
script.call(level: 'WARN', text: "messageWARN")
script.call(level: 'ERROR', text: "messageERROR")
printCallStack()
assertTrue(helper.callStack.findAll { call ->
call.methodName == "echo"
}.any { call ->
!callArgsToString(call).contains("[DEBUG]")
!callArgsToString(call).contains("[INFO]")
callArgsToString(call).contains("[WARN]")
callArgsToString(call).contains("[ERROR]")
})
assertJobStatusSuccess()
}
}
69 changes: 0 additions & 69 deletions src/test/groovy/RunPipelineTests.groovy

This file was deleted.

32 changes: 32 additions & 0 deletions src/test/groovy/WithEnvWrapperStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import org.junit.Before;
import org.junit.Test;
import static com.lesfurets.jenkins.unit.MethodCall.callArgsToString
import static org.junit.Assert.assertTrue
import static org.junit.Assert.assertFalse


class WithEnvWrapperStepTests extends BasePipelineTest {

Expand Down Expand Up @@ -46,6 +48,7 @@ class WithEnvWrapperStepTests extends BasePipelineTest {
helper.registerAllowedMethod("wrap", [Map.class, Closure.class], wrapInterceptor)
helper.registerAllowedMethod("deleteDir", [], { "OK" })
helper.registerAllowedMethod("withEnv", [List.class, Closure.class], withEnvInterceptor)
helper.registerAllowedMethod("dir", [String.class, Closure.class], { path, body -> body() })
}

@Test
Expand All @@ -64,6 +67,35 @@ class WithEnvWrapperStepTests extends BasePipelineTest {
})
printCallStack()
assertTrue(isOK)
assertTrue(helper.callStack.findAll { call ->
call.methodName == "deleteDir"
}?.size()==1)
assertJobStatusSuccess()
}

@Test
void testCleanAfter() throws Exception {
def script = loadScript("vars/withEnvWrapper.groovy")
def isOK = false
script.call(cleanBefore: false, {isOK = true})
printCallStack()
assertTrue(isOK)
assertTrue(helper.callStack.findAll { call ->
call.methodName == "deleteDir"
}?.size()==0)
assertJobStatusSuccess()
}

@Test
void testCleanAfterBefore() throws Exception {
def script = loadScript("vars/withEnvWrapper.groovy")
def isOK = false
script.call(cleanAfter: true, cleanBefore: true, baseDir: 'src', {isOK = true})
printCallStack()
assertTrue(isOK)
assertTrue(helper.callStack.findAll { call ->
call.methodName == "deleteDir"
}?.size()==2)
assertJobStatusSuccess()
}
}
33 changes: 25 additions & 8 deletions vars/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ githubEnv()
* `REPO_NAME`: repository name in the git URL, it sets this environment variable processing the GIT_URL.
* `GIT_SHA`: current commit SHA1, it sets this getting it from local repo.
* `GIT_BUILD_CAUSE`: build cause can be a pull request(pr), a commit, or a merge
## log
Allow to print messages with different levels of verbosity. It will show all messages that match
to an upper log level than defined, the default level is debug.
You have to define the environment variable PIPELINE_LOG_LEVEL to select
the log level by default is INFO.

Levels: DEBUG, INFO, WARN, ERROR

```
log(level: 'INFO', text: 'message')
```

* `level`: sets the verbosity of the messages (DEBUG, INFO, WARN, ERROR)
* `text`: Message to print. The color of the messages depends on the level.
## runIntegrationTestAxis
Run a set of integration test against a Axis of versions.(go, java, nodejs, python, ruby)
It needs the integration test sources stashed.
Expand All @@ -123,14 +137,7 @@ runIntegrationTestAxis(source: 'source', agentType: 'go')
* *agentType*: Agent type to test (all, go, java, python, nodejs, ruby, ...).
* *source*: Stash name that contains the source code.
* *baseDir*: Directory where the code is in the stash code(default 'src/github.com/elastic/apm-integration-testing').
* *elasticStack*: Elastic Stack branch/tag to use(default 'master').## runPipeline
Run a pipeline passed as parameter.

```
runPipeline(name: 'pipeline-name')
```

* name: the pipeline name to execute. ## sendBenchmarks
* *elasticStack*: Elastic Stack branch/tag to use(default 'master').## sendBenchmarks
Send the benchmarks to the cloud service.
Requires Go installed.

Expand Down Expand Up @@ -232,6 +239,16 @@ withEnvWrapper(){
}
```

```
withEnvWrapper(cleanBefore: true, cleanAfter: true, baseDir: 'src'){
//block
}
```

* cleanBefore: clean the workspace before execute the code block.
* cleanAfter: clean the workspace after execute the code block.
* baseDir: directory to work into, if does not exists would be created.

*TODO* replace each variable with a secret text credential type, then use withCredentials step.

```
Expand Down
2 changes: 1 addition & 1 deletion vars/gitCheckout.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def call(Map params = [:]){
} else if (branch && branch != ""
&& repo
&& credentialsId){
echo "Checkout ${branch}"
echo "Checkout ${branch} from ${repo} with credentials ${credentialsId}"
checkout([$class: 'GitSCM', branches: [[name: "${branch}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
Expand Down
Loading