Skip to content

Commit 5facbc2

Browse files
authored
Update Jenkinsfile
1 parent a429703 commit 5facbc2

1 file changed

Lines changed: 62 additions & 20 deletions

File tree

Jenkinsfile

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,67 @@
1-
pipeline {
2-
agent any
3-
stages {
4-
stage('Checkout') {
5-
steps {
6-
echo 'Checkout completed'
7-
}
8-
}
9-
stage('Static-test') {
10-
steps {
11-
echo 'Running static tests on code'
12-
}
1+
pipeline{
2+
agent none
3+
triggers {
4+
cron '* * * * *'
5+
pollSCM 'H/15 * * * *'
6+
}
7+
8+
environment{
9+
AWS_ACCESS_KEY=credentials('aws_access_key')
10+
GITHUB_CRED=credentials('github_cred')
11+
STRING='${params.evar1}'
12+
CHOICE='${params.evar2}'
13+
BOOLEAN='${params.evar3}'
14+
}
15+
parameters{
16+
string(name:'evar1',defaultValue:'jenkins-user',description:'enter your ID')
17+
choice (choices: ['DEV','QA','PROD'],description: 'choose among the choices', name:'evar2')
18+
booleanParam(defaultValue: true, name: 'evar3')
19+
}
20+
stages{
21+
22+
stage('checkout'){
23+
agent {label 'master'}
24+
when{
25+
anyOf{
26+
branch 'main'
27+
branch 'dev'
1328
}
14-
stage('Build') {
15-
steps {
16-
sh 'echo "Building the code"'
17-
}
1829
}
19-
stage('Deploy') {
20-
steps {
21-
echo 'Deploying into environment'
22-
}
30+
steps{
31+
git branch: 'main', url: 'https://github.com/BinduPrivate/java-example.git'
32+
echo 'Hello!!this is user: $STRING'
33+
echo 'checking from the environment: $CHOICE'
34+
echo 'my boolean value is:$BOOLEAN'
35+
}
36+
}
37+
stage('Test'){
38+
agent {label 'java'}
39+
steps{
40+
echo 'Running job ${env.JOB_NAME} on build_id ${env.BUILD_ID} on machine ${env.JENKINS_URL} and build triggered by ${env.USER}'
41+
}
42+
}
43+
stage('Build'){
44+
agent {label 'master'}
45+
when{
46+
expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' }
47+
2348
}
49+
steps{
50+
echo 'bulding artifacts'
51+
echo 'my aws access key is:: $AWS_ACCESS_KEY'
52+
53+
}
54+
}
55+
stage('Deploy'){
56+
agent {label 'java'}
57+
when{
58+
expression { currentBuild.result == null || currentBuild.result == 'SUCCESS' }
59+
}
60+
steps{
61+
echo 'deploying artifacts to environment'
62+
echo 'my github username and password is :: $GITHUB_CRED'
63+
}
2464
}
65+
}
66+
2567
}

0 commit comments

Comments
 (0)