1

I want to fetch project source code from GitLab, archive it and send it via email.

Jenkinsfile:

def gitlabRepo = 'http://repository.vrpconsulting.com/roman.skaskevich/koshcheck-copy.git'
deleteDir()
dir('koshcheck-copy') {
    stage 'Fetch'
    def curdir = pwd()
    echo curdir
    git url: "${gitlabRepo}", branch: 'master'

    stage 'Archive'
    zip archive: true, dir: './src', glob: '', zipFile: 'src.zip'
    def savedZip = archive 'src.zip'
    echo savedZip

    stage 'Notify'
    emailext (
        to: 'roman.skaskevich@gmail.com',
        subject: "ZIP",
        body: "Attached zip must be there",
        attachmentsPattern: 'src.zip'
    )
}

I don't know if project archived successfully, but it isn't sent via email.

EDIT #1

Problem lay in that archive wasn't created. So I perform command which runs local 7zip for create archive: bat "\"C:\\Program Files (x86)\\7-Zip\\7z.exe\" a -tzip src.zip src".

Now remain the problem with sending this archive via email. Because job finished successfully, but returned:

Sending email to: roman.skaskevich@gmail.com

Error sending to the following VALID addresses: roman.skaskevich@gmail.com

I found this article in which suggests, that attachment is too large. But I decrease size of archive from 7MB to 250kB and have the same problem.

Thanks in advance!

Community
  • 1
  • 1
S.Raman
  • 115
  • 3
  • 12
  • That all looks valid and looks like it should work. but zip archive: true and archive 'src.zip' do the same thing so kinda pointless doing both – David van Laatum Nov 05 '17 at 00:18
  • If I right, command `archive` stores archive in the `archive` folder inside the `build` folder. But I see that there is no `archive` folder. So maybe problem lies in the storing file in my filesystem? – S.Raman Nov 05 '17 at 05:17
  • Actually just a thought try attachmentsPattern: '**/src.zip' – David van Laatum Nov 05 '17 at 05:19
  • OK, I will try it! – S.Raman Nov 05 '17 at 05:29
  • I tried it, but now I see that problem lies in the zipping of the project and saving this zip for further use. – S.Raman Nov 06 '17 at 05:13
  • I have a feeling that a number of paths are workspace relative not working directory relative dir('koshcheck-copy') { may be what is breaking it – David van Laatum Nov 06 '17 at 05:14
  • Sorry, I don't know exactly what did you mean. I solved this problem by the hardcoding. But it's the temporary solution. See EDIT #1. – S.Raman Nov 06 '17 at 11:53

0 Answers0