1) Error_Retry
1.1) retry into stage
1 | node{ |
2 | stage( 'build' ){ |
3 | retry( 3 ){ |
4 | error "Error statement just got executed" |
5 | } |
6 | } |
7 | } |
1.2 ) build stage inside a retry block
1 | node{ |
2 | retry( 3 ){ |
3 | stage( 'build' ){ |
4 | error "Error statement just got executed" |
5 | } |
6 | } |
7 | } |
Ở các hình bên dưới nó sẽ try cả stage luôn nhé
1.3) node inside a retry block
1 | retry( 3 ){ |
2 | node{ |
3 | error "Error statement just got executed" |
4 | } |
5 | } |
node được retry 3 lần vì error
2) Timeout
2.1) timeout inside stage
1 | node{ |
2 | stage( 'build' ){ |
3 | timeout(time: 1 , unit: 'SECONDS' ){ |
4 | // sleeping for 2 seconds |
5 | sleep 2 |
6 | } |
7 | } |
8 | } |
2.2 ) build stage inside a retry timeout
1 | node{ |
2 | timeout(time: 1 , unit: 'SECONDS' ){ |
3 | stage( 'build' ){ |
4 | // sleeping for 2 seconds |
5 | sleep 2 |
6 | } |
7 | } |
8 | } |
2.3 ) node inside a retry timeout
1 | timeout(time: 1 , unit: 'SECONDS' ){ |
2 | node{ |
3 | stage( 'build' ){ |
4 | // sleeping for 2 seconds |
5 | sleep 2 |
6 | } |
7 | } |
8 | } |
3) Timestamps
https://newbedev.com/jenkins-pipeline-enable-timestamps-in-build-log-console
Như ở link trên thì bạn cần cài thêm plugin mới chạy được.
3.1) Timestamps for all stage
01 | node{ |
02 | timestamps{ |
03 | stage( 'build' ){ |
04 | echo 'Build stage echo statement printed out with timestamp' |
05 | } |
06 | |
07 | stage( 'deploy' ){ |
08 | echo 'Deploy stage echo statement printed out with timestamp' |
09 | } |
10 | } |
11 | } |
3.1) Timestamps for particular stage
01 | node{ |
02 | stage( 'build' ){ |
03 | timestamps{ |
04 | echo 'Build stage echo statement printed out with timestamp' |
05 | } |
06 | } |
07 | |
08 | stage( 'deploy' ){ |
09 | echo 'Deploy stage echo statement printed out with timestamp' |
10 | } |
11 | } |